diff --git a/.vscode/settings.json b/.vscode/settings.json
index 8bfa895fc..1d5a45a67 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -61,6 +61,6 @@
"html",
"vue"
],
- "typescript.preferences.importModuleSpecifier": "relative",
+ "typescript.preferences.importModuleSpecifier": "shortest",
"typescript.updateImportsOnFileMove.enabled": "always"
}
diff --git a/apps/admin/CHANGELOG.md b/apps/admin/CHANGELOG.md
index ec2f7c951..32b24c4b4 100644
--- a/apps/admin/CHANGELOG.md
+++ b/apps/admin/CHANGELOG.md
@@ -2,6 +2,14 @@
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
+# [2.1.0-next.1](https://github.com/tractr/traxion/compare/v2.1.0-next.0...v2.1.0-next.1) (2023-02-27)
+
+
+
+# [2.1.0-next.0](https://github.com/tractr/traxion/compare/v2.0.13...v2.1.0-next.0) (2023-02-27)
+
+
+
## [2.0.13](https://github.com/tractr/traxion/compare/v2.0.12...v2.0.13) (2023-02-24)
diff --git a/apps/api/CHANGELOG.md b/apps/api/CHANGELOG.md
index 4b5079c0c..d881da8b0 100644
--- a/apps/api/CHANGELOG.md
+++ b/apps/api/CHANGELOG.md
@@ -2,6 +2,41 @@
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
+# [2.1.0-next.1](https://github.com/tractr/traxion/compare/v2.1.0-next.0...v2.1.0-next.1) (2023-02-27)
+
+
+
+# [2.1.0-next.0](https://github.com/tractr/traxion/compare/v2.0.13...v2.1.0-next.0) (2023-02-27)
+
+
+
+## [2.0.11-next.3](https://github.com/tractr/traxion/compare/v2.0.11-next.2...v2.0.11-next.3) (2023-02-22)
+
+
+
+## [2.0.11-next.2](https://github.com/tractr/traxion/compare/v2.0.11-next.1...v2.0.11-next.2) (2023-02-22)
+
+
+
+## [2.0.11-next.1](https://github.com/tractr/traxion/compare/v2.0.11-next.0...v2.0.11-next.1) (2023-02-22)
+
+
+
+## [2.0.11-next.0](https://github.com/tractr/traxion/compare/v2.0.10...v2.0.11-next.0) (2023-02-22)
+
+
+### Bug Fixes
+
+* resolve conversation and make the api start without settings env ([87d4465](https://github.com/tractr/traxion/commit/87d446509dd3c182c92a9d269dfbe24a826899ec))
+* update mailer to use mailjet v6 ([2a4a060](https://github.com/tractr/traxion/commit/2a4a0607963235cbb859e8ff99794829f7eaaf58))
+
+
+### Features
+
+* clean authentication modules ([99b7db6](https://github.com/tractr/traxion/commit/99b7db69cc4f885ac885d147043003448895d66d))
+
+
+
## [2.0.13](https://github.com/tractr/traxion/compare/v2.0.12...v2.0.13) (2023-02-24)
diff --git a/apps/api/package.json b/apps/api/package.json
index 88fa2e52a..0c58043f3 100644
--- a/apps/api/package.json
+++ b/apps/api/package.json
@@ -1,4 +1,4 @@
{
"name": "@trxn/traxion-api",
- "version": "2.0.13"
+ "version": "2.1.0-next.1"
}
diff --git a/apps/api/src/app/app.module.ts b/apps/api/src/app/app.module.ts
index 2bb90d94e..3905a7784 100644
--- a/apps/api/src/app/app.module.ts
+++ b/apps/api/src/app/app.module.ts
@@ -1,8 +1,10 @@
import { Module } from '@nestjs/common';
+import { APP_GUARD, APP_INTERCEPTOR } from '@nestjs/core';
import { ConsoleModule } from 'nestjs-console';
import {
AuthenticationModule,
+ CaslModule,
DatabaseModule,
FileStorageModule,
GraphQLModule,
@@ -11,6 +13,8 @@ import {
PasswordModule,
} from './modules';
+import { JwtGlobalAuthGuard } from '@trxn/nestjs-authentication';
+import { CaslExceptionInterceptor, PoliciesGuard } from '@trxn/nestjs-casl';
import { LoggerModule } from '@trxn/nestjs-core';
@Module({
@@ -23,6 +27,7 @@ import { LoggerModule } from '@trxn/nestjs-core';
GraphQLModule,
// Authentication modules
+ CaslModule,
AuthenticationModule,
PasswordModule,
@@ -36,5 +41,11 @@ import { LoggerModule } from '@trxn/nestjs-core';
// Cli
ConsoleModule,
],
+
+ providers: [
+ { provide: APP_GUARD, useClass: JwtGlobalAuthGuard },
+ { provide: APP_GUARD, useClass: PoliciesGuard },
+ { provide: APP_INTERCEPTOR, useClass: CaslExceptionInterceptor },
+ ],
})
export class AppModule {}
diff --git a/apps/api/src/app/modules/authentication.module.ts b/apps/api/src/app/modules/authentication.module.ts
index 73d0be8a1..66e618ca0 100644
--- a/apps/api/src/app/modules/authentication.module.ts
+++ b/apps/api/src/app/modules/authentication.module.ts
@@ -1,42 +1,20 @@
import { Module } from '@nestjs/common';
-import { APP_GUARD, APP_INTERCEPTOR } from '@nestjs/core';
-import { CaslModule } from './casl.module';
-import { EncryptionModule } from './encryption.module';
-import { ModelsModule } from './models.module';
+import { UserModule } from './user.module';
import { getSelectPrismaUserQuery } from '@trxn/generated-casl';
-import { USER_SERVICE } from '@trxn/generated-nestjs-models-common';
-import {
- JwtGlobalAuthGuard,
- AuthenticationModule as TraxionAuthenticationModule,
-} from '@trxn/nestjs-authentication';
-import { BcryptService } from '@trxn/nestjs-bcrypt';
-import { CaslExceptionInterceptor, PoliciesGuard } from '@trxn/nestjs-casl';
+import { AuthenticationModule as TraxionAuthenticationModule } from '@trxn/nestjs-authentication';
@Module({
imports: [
- CaslModule,
- TraxionAuthenticationModule.registerAsync({
- imports: [ModelsModule, EncryptionModule],
- useFactory: (userService, encryptionService) => ({
- user: {
- customSelect: getSelectPrismaUserQuery(),
- },
- jwtModuleOptions: {
- secret: 'secret',
- },
- userService,
- encryptionService,
- }),
- inject: [USER_SERVICE, BcryptService],
+ TraxionAuthenticationModule.register({
+ imports: [UserModule],
+ customSelect: getSelectPrismaUserQuery(),
+ jwtModuleOptions: {
+ secret: 'secret',
+ },
}),
],
- providers: [
- { provide: APP_GUARD, useClass: JwtGlobalAuthGuard },
- { provide: APP_GUARD, useClass: PoliciesGuard },
- { provide: APP_INTERCEPTOR, useClass: CaslExceptionInterceptor },
- ],
exports: [TraxionAuthenticationModule],
})
export class AuthenticationModule {}
diff --git a/apps/api/src/app/modules/casl.module.ts b/apps/api/src/app/modules/casl.module.ts
index 53c6ef2c8..06284361b 100644
--- a/apps/api/src/app/modules/casl.module.ts
+++ b/apps/api/src/app/modules/casl.module.ts
@@ -7,6 +7,10 @@ import { CaslModule as TraxionCaslModule } from '@trxn/nestjs-casl';
imports: [
TraxionCaslModule.register({
rolePermissions,
+ getRoles: (user) => user.roles,
+ publicPermissions: (ability) => {
+ ability.can('read', 'all');
+ },
}),
],
exports: [TraxionCaslModule],
diff --git a/apps/api/src/app/modules/mailer.module.ts b/apps/api/src/app/modules/mailer.module.ts
index d18c521a0..666b26d57 100644
--- a/apps/api/src/app/modules/mailer.module.ts
+++ b/apps/api/src/app/modules/mailer.module.ts
@@ -1,14 +1,18 @@
import { Module } from '@nestjs/common';
import { MailerModule as TraxionMailerModule } from '@trxn/nestjs-mailer';
+import { MailjetModule, MailjetService } from '@trxn/nestjs-mailjet';
@Module({
imports: [
- TraxionMailerModule.registerAsync({
- useFactory: () => ({
- privateApiKey: 'test',
- publicApiKey: 'test',
- }),
+ TraxionMailerModule.register({
+ imports: [
+ MailjetModule.register({
+ apiKey: process.env.MAILJET_API_KEY || 'apiKey',
+ apiSecret: process.env.MAILJET_API_SECRET || 'apiSecret',
+ }),
+ ],
+ MailerClient: MailjetService,
}),
],
exports: [TraxionMailerModule],
diff --git a/apps/api/src/app/modules/password.module.ts b/apps/api/src/app/modules/password.module.ts
index 86aeb70fa..0dc37bd2a 100644
--- a/apps/api/src/app/modules/password.module.ts
+++ b/apps/api/src/app/modules/password.module.ts
@@ -2,36 +2,24 @@ import { Module } from '@nestjs/common';
import { EncryptionModule } from './encryption.module';
import { MailerModule } from './mailer.module';
-import { ModelsModule } from './models.module';
+import { UserModule } from './user.module';
-import { USER_SERVICE } from '@trxn/generated-nestjs-models-common';
-import { BcryptService, EncryptionService } from '@trxn/nestjs-bcrypt';
-import { ResetPasswordSendEmailService } from '@trxn/nestjs-mailer';
-import { PasswordModule as TraxionPasswordModule } from '@trxn/nestjs-password';
+import { BcryptService } from '@trxn/nestjs-bcrypt';
+import {
+ ENCRYPTION_SERVICE,
+ PasswordModule as TraxionPasswordModule,
+} from '@trxn/nestjs-password';
+import { ResetPasswordModule } from '@trxn/nestjs-reset-password';
@Module({
imports: [
- TraxionPasswordModule.registerAsync({
- imports: [ModelsModule, MailerModule, EncryptionModule],
- useFactory: (
- userService,
- resetPasswordSendEmailService: ResetPasswordSendEmailService,
- encryptionService: EncryptionService,
- ) => ({
- resetPasswordSendEmail: {
- request:
- resetPasswordSendEmailService.sendRequestResetPasswordEmailFactory({
- from: 'admin@traxion.com',
- }),
- updated:
- resetPasswordSendEmailService.sendUpdatedPasswordEmailFactory({
- from: 'admin@traxion.com',
- }),
- },
- userService,
- encryptionService,
- }),
- inject: [USER_SERVICE, ResetPasswordSendEmailService, BcryptService],
+ TraxionPasswordModule.register({
+ imports: [UserModule, EncryptionModule],
+ providers: [{ provide: ENCRYPTION_SERVICE, useExisting: BcryptService }],
+ }),
+ ResetPasswordModule.register({
+ imports: [UserModule, MailerModule],
+ from: 'admin@traxion.com',
}),
],
exports: [TraxionPasswordModule],
diff --git a/apps/api/src/app/modules/user.module.ts b/apps/api/src/app/modules/user.module.ts
new file mode 100644
index 000000000..28d6daad7
--- /dev/null
+++ b/apps/api/src/app/modules/user.module.ts
@@ -0,0 +1,15 @@
+import { Module } from '@nestjs/common';
+
+import { ModelsModule } from './models.module';
+
+import { UserModule as TraxionUserModule } from '@trxn/nestjs-user';
+
+@Module({
+ imports: [
+ TraxionUserModule.register({
+ imports: [ModelsModule],
+ }),
+ ],
+ exports: [TraxionUserModule],
+})
+export class UserModule {}
diff --git a/apps/docs/CHANGELOG.md b/apps/docs/CHANGELOG.md
index 62f9d04bc..8223972e5 100644
--- a/apps/docs/CHANGELOG.md
+++ b/apps/docs/CHANGELOG.md
@@ -2,6 +2,45 @@
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
+# [2.1.0-next.1](https://github.com/tractr/traxion/compare/v2.1.0-next.0...v2.1.0-next.1) (2023-02-27)
+
+
+
+# [2.1.0-next.0](https://github.com/tractr/traxion/compare/v2.0.13...v2.1.0-next.0) (2023-02-27)
+
+
+
+## [2.0.11-next.3](https://github.com/tractr/traxion/compare/v2.0.11-next.2...v2.0.11-next.3) (2023-02-22)
+
+
+
+## [2.0.11-next.2](https://github.com/tractr/traxion/compare/v2.0.11-next.1...v2.0.11-next.2) (2023-02-22)
+
+
+### Bug Fixes
+
+* add casl public permissions and MAILER_CLIENT token ([46f4b06](https://github.com/tractr/traxion/commit/46f4b06da9d46a79c36bde365cd817b46031e24f))
+
+
+
+## [2.0.11-next.1](https://github.com/tractr/traxion/compare/v2.0.11-next.0...v2.0.11-next.1) (2023-02-22)
+
+
+### Bug Fixes
+
+* remove [@tractr](https://github.com/tractr) and replace it by [@trxn](https://github.com/trxn) ([129058f](https://github.com/tractr/traxion/commit/129058fee9f88c34ac4f124f9d1d54470939a0e7))
+
+
+
+## [2.0.11-next.0](https://github.com/tractr/traxion/compare/v2.0.10...v2.0.11-next.0) (2023-02-22)
+
+
+### Features
+
+* clean authentication modules ([99b7db6](https://github.com/tractr/traxion/commit/99b7db69cc4f885ac885d147043003448895d66d))
+
+
+
## [2.0.13](https://github.com/tractr/traxion/compare/v2.0.12...v2.0.13) (2023-02-24)
diff --git a/apps/docs/docs/how-to/authentication/0-use-nestjs-user.mdx b/apps/docs/docs/how-to/authentication/0-use-nestjs-user.mdx
new file mode 100644
index 000000000..11ffdaab2
--- /dev/null
+++ b/apps/docs/docs/how-to/authentication/0-use-nestjs-user.mdx
@@ -0,0 +1,9 @@
+---
+id: use-nestjs-user
+hide_title: true
+sidebar_label: The user module
+---
+
+import SourceMarkdown from '../../../../../libs/nestjs/user/README.md';
+
+
diff --git a/apps/docs/docs/how-to/authentication/1-use-nestjs-authentication copy.mdx b/apps/docs/docs/how-to/authentication/1-use-nestjs-authentication copy.mdx
new file mode 100644
index 000000000..5723b97cb
--- /dev/null
+++ b/apps/docs/docs/how-to/authentication/1-use-nestjs-authentication copy.mdx
@@ -0,0 +1,9 @@
+---
+id: use-nestjs-authentication
+hide_title: true
+sidebar_label: Authenticate your routes
+---
+
+import SourceMarkdown from '../../../../../libs/nestjs/authentication/README.md';
+
+
diff --git a/apps/docs/docs/how-to/authentication/2-use-nestjs-casl.mdx b/apps/docs/docs/how-to/authentication/2-use-nestjs-casl.mdx
new file mode 100644
index 000000000..9cc97e8fb
--- /dev/null
+++ b/apps/docs/docs/how-to/authentication/2-use-nestjs-casl.mdx
@@ -0,0 +1,9 @@
+---
+id: use-nestjs-casl
+hide_title: true
+sidebar_label: Authorization
+---
+
+import SourceMarkdown from '../../../../../libs/nestjs/casl/README.md';
+
+
diff --git a/apps/docs/docs/how-to/authentication/3-use-nestjs-password copy.mdx b/apps/docs/docs/how-to/authentication/3-use-nestjs-password copy.mdx
new file mode 100644
index 000000000..f70d3298f
--- /dev/null
+++ b/apps/docs/docs/how-to/authentication/3-use-nestjs-password copy.mdx
@@ -0,0 +1,12 @@
+---
+id: use-nestjs-password
+hide_title: true
+sidebar_label: Play with the password
+---
+
+import PasswordMarkdown from '../../../../../libs/nestjs/password/README.md';
+import ResetPasswordMarkdown from '../../../../../libs/nestjs/reset-password/README.md';
+
+
+
+
diff --git a/apps/docs/docs/how-to/file-storage/file-storage-on-aws-s3.md b/apps/docs/docs/how-to/file-storage/file-storage-on-aws-s3.md
index 176731cff..4f9846fea 100644
--- a/apps/docs/docs/how-to/file-storage/file-storage-on-aws-s3.md
+++ b/apps/docs/docs/how-to/file-storage/file-storage-on-aws-s3.md
@@ -42,32 +42,32 @@ import {
@Module({
imports: [
FileStorageModule.register({
- // Public key of your file storage user
+ // Public key of your file storage user
accessKey: 'minio',
- // Private key of your file storage user
+ // Private key of your file storage user
secretKey: 'password',
- // Domain to access the file storage
+ // Domain to access the file storage
endPoint: 'localhost',
- // Port to access the file storage
+ // Port to access the file storage
port: 9000,
- // Denotes if ssl should be used
+ // Denotes if ssl should be used
// (can be disabled for dev envs, but should be used in production)
useSSL: false,
- // The name of your file storage bucket
+ // The name of your file storage bucket
defaultBucket: 'bucket',
- // Here you can configure the validity time of presigned download urls
- // (default to 300s)
+ // Here you can configure the validity time of presigned download urls
+ // (default to 300s)
presignedDownload: {} as PresignedDownloadConfiguration,
- // Here you can configure the validity time of presigned download urls
- // (default to 300s)
- // You can also add restrictions on allowed file size and mime type
+ // Here you can configure the validity time of presigned download urls
+ // (default to 300s)
+ // You can also add restrictions on allowed file size and mime type
presignedUpload: {} as PresignedUploadConfiguration,
}),
],
@@ -85,13 +85,13 @@ import { FileStorageModule } from '@trxn/angular-file-storage';
@NgModule({
imports: [
FileStorageModule.register({
- // The name of your file storage bucket
+ // The name of your file storage bucket
defaultBucket: 'bucket',
-
- // Endpoint to request presigned upload url (default to 'upload')
+
+ // Endpoint to request presigned upload url (default to 'upload')
presignedUploadEndpoint: 'upload',
- // Endpoint to request presigned download url (default to 'download')
+ // Endpoint to request presigned download url (default to 'download')
presignedDownloadEndpoint: 'download',
}),
],
@@ -136,8 +136,8 @@ Simply import it from `@trxn/nestjs-file-storage` and add it to your `app.module
// file: apps/api/src/app/app.module.ts
import {
- FileStorageModule,
- FileStorageController
+ FileStorageModule,
+ FileStorageController
} from '@trxn/nestjs-file-storage';
@Module({
@@ -163,7 +163,7 @@ The `FileStorageController` exposes two endpoints:
- The `upload` endpoint can be used to request an upload presigned URL.
- The `download` endpoint can be used to request a download presigned URL.
-On the frontend side of your application, you can use the `tractr-file-storage-upload-button` button component exported from `@tractr/angular-file-storage` to automatically send files uploaded by the users to the file storage.
+On the frontend side of your application, you can use the `tractr-file-storage-upload-button` button component exported from `@trxn/angular-file-storage` to automatically send files uploaded by the users to the file storage.
Then you should listen to the `uploadResult` event to get information about the uploaded file.
@@ -244,9 +244,9 @@ NestJS controller example:
import { Controller, Get, Query } from '@nestjs/common';
import {
- GetPresignedDownloadUrlQueryDto,
+ GetPresignedDownloadUrlQueryDto,
GetPresignedUploadUrlQueryDto,
- FileStorageService
+ FileStorageService
} from '@trxn/nestjs-file-storage';
@Controller('file-storage')
@@ -259,16 +259,16 @@ export class FileStorageController {
@Get('upload')
getPresignedUploadUrl(@Query() queryDto: GetPresignedUploadUrlQueryDto) {
- // Business logique could be added here or in some nestjs guards
+ // Business logique could be added here or in some nestjs guards
const { mimeType, fileSize } = queryDto;
- // Request presigned url to the file storage and returns it
+ // Request presigned url to the file storage and returns it
return this.fileStorageService.getPresignedUploadUrl(mimeType, fileSize);
}
}
```
-### Download a file from file storage with a presigned URL.
+### Download a file from file storage with a presigned URL
Read access to a file can also be restricted by using presigned URLs for downloading. The mechanism is very similar to the one presented in the upload section.
@@ -316,7 +316,7 @@ import { Controller, Get, Query } from '@nestjs/common';
import {
GetPresignedDownloadUrlQueryDto,
GetPresignedUploadUrlQueryDto,
- FileStorageService
+ FileStorageService
} from '@trxn/nestjs-file-storage';
@Controller('file-storage')
@@ -331,10 +331,10 @@ export class FileStorageController {
@Query() queryDto: GetPresignedDownloadUrlQueryDto,
) {
- // Business logique could be added here or in some nestjs guards
+ // Business logique could be added here or in some nestjs guards
const { file } = queryDto;
- // Request presigned url to the file storage and returns it
+ // Request presigned url to the file storage and returns it
const url = await this.fileStorageService.getPresignedDownloadUrl(file);
return { url };
}
@@ -362,25 +362,25 @@ import { FileStorageService } from '@trxn/nestjs-file-storage';
Injectable()
export class UserService {
-
- constructor(private fileStorageService: FileStorageService) {}
-
- async create(user: User) {
- const avatarImageTempPath = user.avatarUrl;
- const avatarImageDefinitivePath = `images/${uuid()}.jpg`;
-
- try {
- // Move the file out of the temporary folder
- await this.fileStorageService.commitTemporaryFile(
- avatarImageTempPath,
- avatarImageDefinitivePath
- );
- } catch (e) {
- // handle potential errors with the file storage
- }
- //...
- // Save your user with the new avatar path
- }
+
+ constructor(private fileStorageService: FileStorageService) {}
+
+ async create(user: User) {
+ const avatarImageTempPath = user.avatarUrl;
+ const avatarImageDefinitivePath = `images/${uuid()}.jpg`;
+
+ try {
+ // Move the file out of the temporary folder
+ await this.fileStorageService.commitTemporaryFile(
+ avatarImageTempPath,
+ avatarImageDefinitivePath
+ );
+ } catch (e) {
+ // handle potential errors with the file storage
+ }
+ //...
+ // Save your user with the new avatar path
+ }
}
```
@@ -397,4 +397,3 @@ This method should be called periodically (e.g. in a Cron) if you don't want the
The NestJS `FileStorageService` uses the Minio javascript client and extends it, making all the Minio client methods available for custom operations as well. For more information, please refer to the [Minio documentation](https://min.io/docs/minio/linux/developers/javascript/API.html).
:::
-
diff --git a/apps/docs/docs/how-to/mailer/use-mailer-with-mailjet.mdx b/apps/docs/docs/how-to/mailer/use-mailer-with-mailjet.mdx
new file mode 100644
index 000000000..b3521110f
--- /dev/null
+++ b/apps/docs/docs/how-to/mailer/use-mailer-with-mailjet.mdx
@@ -0,0 +1,9 @@
+---
+id: use-mailer-with-mailjet
+hide_title: true
+sidebar_label: Configure Mailer with MailjetModule
+---
+
+import SourceMarkdown from '../../../../../libs/nestjs/mailer/README.md';
+
+
diff --git a/apps/docs/docs/how-to/mailer/use-mailjet.mdx b/apps/docs/docs/how-to/mailer/use-mailjet.mdx
new file mode 100644
index 000000000..c2e0969a9
--- /dev/null
+++ b/apps/docs/docs/how-to/mailer/use-mailjet.mdx
@@ -0,0 +1,9 @@
+---
+id: use-mailjet
+hide_title: true
+sidebar_label: Configure Mailjet
+---
+
+import SourceMarkdown from '../../../../../libs/nestjs/mailjet/README.md';
+
+
diff --git a/apps/docs/docs/how-to/terraform/configuration.md b/apps/docs/docs/how-to/terraform/configuration.md
index 6543985b5..17668282f 100644
--- a/apps/docs/docs/how-to/terraform/configuration.md
+++ b/apps/docs/docs/how-to/terraform/configuration.md
@@ -11,7 +11,6 @@ Soon, schematics will automate some or all of these manual operations.
:::
-
## Install libraries
The following libraries are required by the `terraform` application we will create:
@@ -22,13 +21,13 @@ npm install --save \
cdktf \
cdktf-cli \
@cdktf/provider-aws \
- @tractr/terraform-aws-stack \
- @tractr/terraform-group-network \
- @tractr/terraform-group-pool \
- @tractr/terraform-group-registry \
- @tractr/terraform-group-zone \
- @tractr/terraform-service-api \
- @tractr/terraform-service-postgres \
- @tractr/terraform-service-pwa \
- @tractr/terraform-service-reverse-proxy
+ @trxn/terraform-aws-stack \
+ @trxn/terraform-group-network \
+ @trxn/terraform-group-pool \
+ @trxn/terraform-group-registry \
+ @trxn/terraform-group-zone \
+ @trxn/terraform-service-api \
+ @trxn/terraform-service-postgres \
+ @trxn/terraform-service-pwa \
+ @trxn/terraform-service-reverse-proxy
```
diff --git a/apps/docs/package.json b/apps/docs/package.json
index 5f821b866..81b29d9cd 100644
--- a/apps/docs/package.json
+++ b/apps/docs/package.json
@@ -1,6 +1,6 @@
{
"name": "@trxn/traxion-api",
- "version": "2.0.13",
+ "version": "2.1.0-next.1",
"dependencies": {
"@docusaurus/core": "^2.2.0",
"@docusaurus/mdx-loader": "^2.2.0",
diff --git a/apps/docs/sidebars.js b/apps/docs/sidebars.js
index e0cedaac6..63c963485 100644
--- a/apps/docs/sidebars.js
+++ b/apps/docs/sidebars.js
@@ -13,28 +13,36 @@ module.exports = {
items: [
{
type: 'category',
- label: 'Angular',
+ label: 'Database',
items: [
- 'how-to/angular/configure-lazy-loading',
- 'how-to/angular/configure-storybook',
- 'how-to/angular/configure-tailwind-css',
+ 'how-to/database/configuration',
+ 'how-to/database/database-migration-with-prisma',
],
},
{
type: 'category',
- label: 'NestJS',
+ label: 'Authentication',
items: [
- 'how-to/nestjs/extend-a-generated-controller',
+ 'how-to/authentication/use-nestjs-user',
+ 'how-to/authentication/use-nestjs-authentication',
+ 'how-to/authentication/use-nestjs-casl',
+ 'how-to/authentication/use-nestjs-password',
],
},
{
type: 'category',
- label: 'Database',
+ label: 'Angular',
items: [
- 'how-to/database/configuration',
- 'how-to/database/database-migration-with-prisma'
+ 'how-to/angular/configure-lazy-loading',
+ 'how-to/angular/configure-storybook',
+ 'how-to/angular/configure-tailwind-css',
],
},
+ {
+ type: 'category',
+ label: 'NestJS',
+ items: ['how-to/nestjs/extend-a-generated-controller'],
+ },
{
type: 'category',
label: 'File storage',
@@ -43,6 +51,14 @@ module.exports = {
'how-to/file-storage/use-minio',
],
},
+ {
+ type: 'category',
+ label: 'Mailer',
+ items: [
+ 'how-to/mailer/use-mailjet',
+ 'how-to/mailer/use-mailer-with-mailjet',
+ ],
+ },
{
type: 'category',
label: 'Terraform',
diff --git a/apps/pwa-e2e/CHANGELOG.md b/apps/pwa-e2e/CHANGELOG.md
index 75557c299..a1f3a97c0 100644
--- a/apps/pwa-e2e/CHANGELOG.md
+++ b/apps/pwa-e2e/CHANGELOG.md
@@ -2,6 +2,14 @@
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
+# [2.1.0-next.1](https://github.com/tractr/traxion/compare/v2.1.0-next.0...v2.1.0-next.1) (2023-02-27)
+
+
+
+# [2.1.0-next.0](https://github.com/tractr/traxion/compare/v2.0.13...v2.1.0-next.0) (2023-02-27)
+
+
+
## [2.0.13](https://github.com/tractr/traxion/compare/v2.0.12...v2.0.13) (2023-02-24)
diff --git a/apps/pwa/CHANGELOG.md b/apps/pwa/CHANGELOG.md
index 682ca25fd..e1de3d404 100644
--- a/apps/pwa/CHANGELOG.md
+++ b/apps/pwa/CHANGELOG.md
@@ -2,6 +2,35 @@
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
+# [2.1.0-next.1](https://github.com/tractr/traxion/compare/v2.1.0-next.0...v2.1.0-next.1) (2023-02-27)
+
+
+
+# [2.1.0-next.0](https://github.com/tractr/traxion/compare/v2.0.13...v2.1.0-next.0) (2023-02-27)
+
+
+
+## [2.0.11-next.3](https://github.com/tractr/traxion/compare/v2.0.11-next.2...v2.0.11-next.3) (2023-02-22)
+
+
+
+## [2.0.11-next.2](https://github.com/tractr/traxion/compare/v2.0.11-next.1...v2.0.11-next.2) (2023-02-22)
+
+
+
+## [2.0.11-next.1](https://github.com/tractr/traxion/compare/v2.0.11-next.0...v2.0.11-next.1) (2023-02-22)
+
+
+
+## [2.0.11-next.0](https://github.com/tractr/traxion/compare/v2.0.10...v2.0.11-next.0) (2023-02-22)
+
+
+### Features
+
+* clean authentication modules ([99b7db6](https://github.com/tractr/traxion/commit/99b7db69cc4f885ac885d147043003448895d66d))
+
+
+
## [2.0.13](https://github.com/tractr/traxion/compare/v2.0.12...v2.0.13) (2023-02-24)
diff --git a/apps/pwa/package.json b/apps/pwa/package.json
index f5ab589db..be6dde6a0 100644
--- a/apps/pwa/package.json
+++ b/apps/pwa/package.json
@@ -1,6 +1,6 @@
{
"name": "@trxn/traxion-pwa",
- "version": "2.0.13",
+ "version": "2.1.0-next.1",
"peerDependencies": {
"@angular/common": "^12.1.1",
"@angular/core": "^12.1.1"
diff --git a/apps/pwa/src/app/app.module.ts b/apps/pwa/src/app/app.module.ts
index 58296dace..e4309eddd 100644
--- a/apps/pwa/src/app/app.module.ts
+++ b/apps/pwa/src/app/app.module.ts
@@ -6,9 +6,9 @@ import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { RouterModule } from '@angular/router';
import { User as UserType } from '@prisma/client';
-import { AppConfig } from '../environments/environment';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
+import { AppConfig } from '../environments/environment';
import {
AngularAuthenticationModule,
diff --git a/apps/terraform/CHANGELOG.md b/apps/terraform/CHANGELOG.md
index ea1b2d98c..a18d8ebe1 100644
--- a/apps/terraform/CHANGELOG.md
+++ b/apps/terraform/CHANGELOG.md
@@ -2,6 +2,14 @@
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
+# [2.1.0-next.1](https://github.com/tractr/traxion/compare/v2.1.0-next.0...v2.1.0-next.1) (2023-02-27)
+
+
+
+# [2.1.0-next.0](https://github.com/tractr/traxion/compare/v2.0.13...v2.1.0-next.0) (2023-02-27)
+
+
+
## [2.0.13](https://github.com/tractr/traxion/compare/v2.0.12...v2.0.13) (2023-02-24)
diff --git a/jest.config.ts b/jest.config.ts
index 7af4b6527..f4bfeb76b 100644
--- a/jest.config.ts
+++ b/jest.config.ts
@@ -74,5 +74,6 @@ export default {
'/apps/pwa',
'/libs/nestjs/password',
'/libs/config/client',
+ '/libs/nestjs/mailjet',
],
};
diff --git a/libs/angular/authentication/CHANGELOG.md b/libs/angular/authentication/CHANGELOG.md
index b44cc076f..c8d8000af 100644
--- a/libs/angular/authentication/CHANGELOG.md
+++ b/libs/angular/authentication/CHANGELOG.md
@@ -2,944 +2,106 @@
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
-## [2.0.13](https://github.com/tractr/traxion/compare/v2.0.12...v2.0.13) (2023-02-24)
-
-
-
-## [2.0.12](https://github.com/tractr/traxion/compare/v2.0.11...v2.0.12) (2023-02-23)
+# [2.1.0-next.1](https://github.com/tractr/traxion/compare/v2.1.0-next.0...v2.1.0-next.1) (2023-02-27)
-## [2.0.11](https://github.com/tractr/traxion/compare/v2.0.10...v2.0.11) (2023-02-23)
+# [2.1.0-next.0](https://github.com/tractr/traxion/compare/v2.0.13...v2.1.0-next.0) (2023-02-27)
-## [2.0.10](https://github.com/tractr/traxion/compare/v2.0.9...v2.0.10) (2023-02-14)
+## [2.0.11-next.3](https://github.com/tractr/traxion/compare/v2.0.11-next.2...v2.0.11-next.3) (2023-02-22)
-## [2.0.9](https://github.com/tractr/traxion/compare/v2.0.8...v2.0.9) (2023-02-14)
-
+## [2.0.11-next.2](https://github.com/tractr/traxion/compare/v2.0.11-next.1...v2.0.11-next.2) (2023-02-22)
-## [2.0.8](https://github.com/tractr/traxion/compare/v2.0.7...v2.0.8) (2023-02-14)
+## [2.0.11-next.1](https://github.com/tractr/traxion/compare/v2.0.11-next.0...v2.0.11-next.1) (2023-02-22)
-## [2.0.7](https://github.com/tractr/traxion/compare/v2.0.6...v2.0.7) (2023-02-09)
+## [2.0.11-next.0](https://github.com/tractr/traxion/compare/v2.0.10...v2.0.11-next.0) (2023-02-22)
-## [2.0.6](https://github.com/tractr/traxion/compare/v2.0.5...v2.0.6) (2023-02-09)
+## [2.0.13](https://github.com/tractr/traxion/compare/v2.0.12...v2.0.13) (2023-02-24)
+## [2.0.9](https://github.com/tractr/traxion/compare/v2.0.8...v2.0.9) (2023-02-14)
## [2.0.5](https://github.com/tractr/traxion/compare/v2.0.4...v2.0.5) (2023-02-07)
-
-
-## [2.0.4](https://github.com/tractr/traxion/compare/v2.0.3...v2.0.4) (2023-02-07)
-
-
-
-## [2.0.3](https://github.com/tractr/traxion/compare/v2.0.2...v2.0.3) (2023-02-06)
-
-
-
-## [2.0.2](https://github.com/tractr/traxion/compare/v2.0.1...v2.0.2) (2023-02-06)
-
-
-
## [2.0.1](https://github.com/tractr/traxion/compare/v2.0.0...v2.0.1) (2023-02-06)
-
-
-# [2.0.0](https://github.com/tractr/traxion/compare/v1.65.12...v2.0.0) (2023-02-06)
-
-
-### chore
-
-* migrate nx and angular to version 15 ([#556](https://github.com/tractr/traxion/issues/556)) ([6b8973d](https://github.com/tractr/traxion/commit/6b8973df221203b035437c248c74f03d8f582ba2)), closes [#555](https://github.com/tractr/traxion/issues/555) [#557](https://github.com/tractr/traxion/issues/557) [#558](https://github.com/tractr/traxion/issues/558) [#560](https://github.com/tractr/traxion/issues/560) [#536](https://github.com/tractr/traxion/issues/536)
-
-
### BREAKING CHANGES
-* Updating angular and nx to 15 will not work with nx 14 and angular 14 packages
-
-* chore: update major packages version
-
-* chore(prerelease): prerelease next version 1.65.13-next.1
-
-
-
# [2.0.0-next.2](https://github.com/tractr/traxion/compare/v2.0.0-next.1...v2.0.0-next.2) (2023-02-06)
-
-
-# [2.0.0-next.1](https://github.com/tractr/traxion/compare/v2.0.0-next.0...v2.0.0-next.1) (2023-02-06)
-
-
-
-# [2.0.0-next.0](https://github.com/tractr/traxion/compare/v1.65.13-next.8...v2.0.0-next.0) (2023-02-06)
-
-
-
-## [1.65.13-next.8](https://github.com/tractr/traxion/compare/v1.65.13-next.7...v1.65.13-next.8) (2023-01-26)
-
-
-
## [1.65.13-next.7](https://github.com/tractr/traxion/compare/v1.65.13-next.6...v1.65.13-next.7) (2023-01-26)
-
-
-## [1.65.13-next.6](https://github.com/tractr/traxion/compare/v1.65.13-next.5...v1.65.13-next.6) (2023-01-26)
-
-
-
-## [1.65.13-next.5](https://github.com/tractr/traxion/compare/v1.65.13-next.4...v1.65.13-next.5) (2023-01-26)
-
-
-
-## [1.65.13-next.4](https://github.com/tractr/traxion/compare/v1.65.13-next.3...v1.65.13-next.4) (2023-01-25)
-
-
-
-## [1.65.13-next.3](https://github.com/tractr/traxion/compare/v1.65.13-next.2...v1.65.13-next.3) (2023-01-25)
-
-
-
-## [1.65.13-next.2](https://github.com/tractr/traxion/compare/v1.65.13-next.1...v1.65.13-next.2) (2023-01-25)
-
-
### Features
-* add peer dependencies executor helper to publish pacakges ([#560](https://github.com/tractr/traxion/issues/560)) ([ddfd62d](https://github.com/tractr/traxion/commit/ddfd62d7109e2023511f2aabe7b4f24ce6dc83e6))
-
-
-
## [1.65.13-next.1](https://github.com/tractr/traxion/compare/v1.65.13-next.0...v1.65.13-next.1) (2023-01-25)
-
-
-## [1.65.13-next.0](https://github.com/tractr/traxion/compare/v1.65.12...v1.65.13-next.0) (2023-01-24)
-
-
-### Features
-
* update major nx and angular dependencies ([#555](https://github.com/tractr/traxion/issues/555)) ([3b2a0cc](https://github.com/tractr/traxion/commit/3b2a0cc282df60e08a31fc58a32a682a37ae5c2b))
-
-
-## [1.65.12](https://github.com/tractr/traxion/compare/v1.65.11...v1.65.12) (2023-01-19)
-
-
-
-## [1.65.11](https://github.com/tractr/traxion/compare/v1.65.10...v1.65.11) (2023-01-19)
-
-
-### Bug Fixes
-
* update schematics to match the last updates with traxion best practices ([#551](https://github.com/tractr/traxion/issues/551)) ([7512b4a](https://github.com/tractr/traxion/commit/7512b4a69e2b82c09d40651d53b28d17bc61a365))
-
-
-## [1.65.11-next.0](https://github.com/tractr/traxion/compare/v1.65.11-beta.3...v1.65.11-next.0) (2023-01-18)
-
-
-
-## [1.65.11-beta.3](https://github.com/tractr/traxion/compare/v1.65.11-beta.2...v1.65.11-beta.3) (2023-01-18)
-
-
-
-## [1.65.11-beta.2](https://github.com/tractr/traxion/compare/v1.65.11-beta.1...v1.65.11-beta.2) (2023-01-18)
-
-
-
## [1.65.11-beta.1](https://github.com/tractr/traxion/compare/v1.65.11-beta.0...v1.65.11-beta.1) (2023-01-18)
-
-
-## [1.65.11-beta.0](https://github.com/tractr/traxion/compare/v1.65.10...v1.65.11-beta.0) (2023-01-17)
-
-
-
-## [1.65.10](https://github.com/tractr/traxion/compare/v1.65.9...v1.65.10) (2023-01-17)
-
-
-
-## [1.65.9](https://github.com/tractr/traxion/compare/v1.65.8...v1.65.9) (2023-01-10)
-
-
-
## [1.65.8](https://github.com/tractr/traxion/compare/v1.65.7...v1.65.8) (2023-01-10)
-
-
-## [1.65.7](https://github.com/tractr/traxion/compare/v1.65.6...v1.65.7) (2022-12-21)
-
-
-
-## [1.65.6](https://github.com/tractr/traxion/compare/v1.65.5...v1.65.6) (2022-12-20)
-
-
-### Bug Fixes
-
-* update error management in angular-authentication to have details errors ([#542](https://github.com/tractr/traxion/issues/542)) ([e10e55a](https://github.com/tractr/traxion/commit/e10e55ac213a59c561a341363ab23eaaaca172a5))
-
-
-
-## [1.65.5](https://github.com/tractr/traxion/compare/v1.65.4...v1.65.5) (2022-12-19)
-
-
-
-## [1.65.4](https://github.com/tractr/traxion/compare/v1.65.3...v1.65.4) (2022-12-08)
-
-
-
-## [1.65.3](https://github.com/tractr/traxion/compare/v1.65.2...v1.65.3) (2022-12-07)
-
-
-
-## [1.65.2](https://github.com/tractr/traxion/compare/v1.65.1...v1.65.2) (2022-11-30)
-
-
-
-## [1.65.1](https://github.com/tractr/traxion/compare/v1.65.0...v1.65.1) (2022-11-30)
-
-
-
-# [1.65.0](https://github.com/tractr/traxion/compare/v1.64.9...v1.65.0) (2022-11-30)
-
-
-### Features
-
-* change [@tractr](https://github.com/tractr) to [@trxn](https://github.com/trxn) and publish to npmjs registry ([#532](https://github.com/tractr/traxion/issues/532)) ([443668a](https://github.com/tractr/traxion/commit/443668afe75401f4c288f239ee6052c2f7910585))
-
-
-
## [1.64.9](https://github.com/tractr/stack/compare/v1.64.8...v1.64.9) (2022-11-28)
-
-
-## [1.64.8](https://github.com/tractr/stack/compare/v1.64.7...v1.64.8) (2022-11-24)
-
-
-
## [1.64.7](https://github.com/tractr/stack/compare/v1.64.6...v1.64.7) (2022-11-22)
-
-
-## [1.64.6](https://github.com/tractr/stack/compare/v1.64.5...v1.64.6) (2022-11-18)
-
-
-
-## [1.64.5](https://github.com/tractr/stack/compare/v1.64.4...v1.64.5) (2022-11-16)
-
-
-
-## [1.64.4](https://github.com/tractr/stack/compare/v1.64.3...v1.64.4) (2022-11-16)
-
-
-
## [1.64.3](https://github.com/tractr/stack/compare/v1.64.2...v1.64.3) (2022-11-10)
-
-
-## [1.64.2](https://github.com/tractr/stack/compare/v1.64.1...v1.64.2) (2022-11-04)
-
-
-
-## [1.64.1](https://github.com/tractr/stack/compare/v1.64.0...v1.64.1) (2022-11-04)
-
-
-
-# [1.64.0](https://github.com/tractr/stack/compare/v1.63.0...v1.64.0) (2022-11-03)
-
-
-
-# [1.63.0](https://github.com/tractr/stack/compare/v1.62.0...v1.63.0) (2022-10-18)
-
-
-
-# [1.62.0](https://github.com/tractr/stack/compare/v1.61.3...v1.62.0) (2022-10-12)
-
-
-
-## [1.61.3](https://github.com/tractr/stack/compare/v1.61.2...v1.61.3) (2022-10-12)
-
-
-
-## [1.61.2](https://github.com/tractr/stack/compare/v1.61.1...v1.61.2) (2022-10-06)
-
-
-
-## [1.61.1](https://github.com/tractr/stack/compare/v1.61.0...v1.61.1) (2022-10-05)
-
-
-
-# [1.61.0](https://github.com/tractr/stack/compare/v1.60.2...v1.61.0) (2022-09-29)
-
-
-
-## [1.60.2](https://github.com/tractr/stack/compare/v1.60.1...v1.60.2) (2022-09-22)
-
-
-
-## [1.60.1](https://github.com/tractr/stack/compare/v1.60.0...v1.60.1) (2022-09-21)
-
-
-
-# [1.60.0](https://github.com/tractr/stack/compare/v1.59.0...v1.60.0) (2022-09-19)
-
-
-
-# [1.59.0](https://github.com/tractr/stack/compare/v1.58.7...v1.59.0) (2022-09-19)
-
-
-
-## [1.58.7](https://github.com/tractr/stack/compare/v1.58.6...v1.58.7) (2022-09-19)
-
-
-
-## [1.58.6](https://github.com/tractr/stack/compare/v1.58.5...v1.58.6) (2022-09-13)
-
-
-
-## [1.58.5](https://github.com/tractr/stack/compare/v1.58.4...v1.58.5) (2022-09-13)
-
-
-### Bug Fixes
-
-* **authentication:** export controller + fix interface password ([#507](https://github.com/tractr/stack/issues/507)) ([1825cf7](https://github.com/tractr/stack/commit/1825cf799356fbf1df00241c60ad13d95fca9ec8))
-
-
-
-## [1.58.4](https://github.com/tractr/stack/compare/v1.58.3...v1.58.4) (2022-09-08)
-
-
-
-## [1.58.3](https://github.com/tractr/stack/compare/v1.58.2...v1.58.3) (2022-09-08)
-
-
-### Bug Fixes
-
-* **angular-authentication:** fix logout ([#504](https://github.com/tractr/stack/issues/504)) ([fc374e9](https://github.com/tractr/stack/commit/fc374e9e7bb88e468051051a0db0f1f7c80448bf))
-
-
-
## [1.58.2](https://github.com/tractr/stack/compare/v1.58.1...v1.58.2) (2022-09-07)
-
-
-## [1.58.1](https://github.com/tractr/stack/compare/v1.58.0...v1.58.1) (2022-09-06)
-
-
-
# [1.58.0](https://github.com/tractr/stack/compare/v1.57.2...v1.58.0) (2022-09-02)
-
-
-## [1.57.2](https://github.com/tractr/stack/compare/v1.57.1...v1.57.2) (2022-09-01)
-
-
-
-## [1.57.1](https://github.com/tractr/stack/compare/v1.57.0...v1.57.1) (2022-08-31)
-
-
-
-# [1.57.0](https://github.com/tractr/stack/compare/v1.56.1...v1.57.0) (2022-08-31)
-
-
-
## [1.56.1](https://github.com/tractr/stack/compare/v1.56.0...v1.56.1) (2022-08-26)
+## [1.43.5](https://github.com/tractr/stack/compare/v1.43.4...v1.43.5) (2022-04-07)
+## [1.43.1](https://github.com/tractr/stack/compare/v1.43.0...v1.43.1) (2022-04-06)
-# [1.56.0](https://github.com/tractr/stack/compare/v1.55.0...v1.56.0) (2022-08-19)
-
-
-
-# [1.55.0](https://github.com/tractr/stack/compare/v1.54.5...v1.55.0) (2022-08-18)
-
-
-
-## [1.54.5](https://github.com/tractr/stack/compare/v1.54.4...v1.54.5) (2022-08-18)
-
-
+# [1.43.0](https://github.com/tractr/stack/compare/v1.42.1...v1.43.0) (2022-04-05)
-## [1.54.4](https://github.com/tractr/stack/compare/v1.54.3...v1.54.4) (2022-08-17)
+# [1.41.0](https://github.com/tractr/stack/compare/v1.40.0...v1.41.0) (2022-03-03)
+## [1.39.3](https://github.com/tractr/stack/compare/v1.39.2...v1.39.3) (2022-02-22)
+# [1.38.0](https://github.com/tractr/stack/compare/v1.37.1...v1.38.0) (2022-02-17)
-## [1.54.3](https://github.com/tractr/stack/compare/v1.54.2...v1.54.3) (2022-08-17)
+# [1.34.0](https://github.com/tractr/stack/compare/v1.33.0...v1.34.0) (2022-01-31)
+### Features
+* use typeof instead of the dto to type the angular injection token ([#320](https://github.com/tractr/stack/issues/320)) ([4653bdf](https://github.com/tractr/stack/commit/4653bdfe66d458949cea94a61bf615ac703a4cd4))
-## [1.54.2](https://github.com/tractr/stack/compare/v1.54.1...v1.54.2) (2022-08-17)
+## [1.23.1](https://github.com/tractr/stack/compare/v1.23.0...v1.23.1) (2021-11-09)
+## [1.22.2](https://github.com/tractr/stack/compare/v1.22.1...v1.22.2) (2021-10-28)
+## [1.21.3](https://github.com/tractr/stack/compare/v1.21.2...v1.21.3) (2021-10-15)
-## [1.54.1](https://github.com/tractr/stack/compare/v1.54.0...v1.54.1) (2022-08-17)
+## [0.6.4](https://github.com/tractr/stack/compare/angular-authentication-0.6.3...angular-authentication-0.6.4) (2021-09-28)
+### Bug Fixes
+* do not fail when the fetch user fail that cause the whole rx chain to complete with error ([#218](https://github.com/tractr/stack/issues/218)) ([ce6d04f](https://github.com/tractr/stack/commit/ce6d04f702b7b9f9b88e2fdec0ea403bb9f3e9ba))
-# [1.54.0](https://github.com/tractr/stack/compare/v1.53.1...v1.54.0) (2022-08-17)
+* remove the http dependencies from angular config service that was causing circular deps ([#198](https://github.com/tractr/stack/issues/198)) ([c52152a](https://github.com/tractr/stack/commit/c52152a061fcd54bed3a36931c0cf88f05310d8d))
+## [0.4.1](https://github.com/tractr/stack/compare/angular-authentication-0.4.0...angular-authentication-0.4.1) (2021-07-19)
### Features
-* update angular, nestjs, prisma and react-admin ([#468](https://github.com/tractr/stack/issues/468)) ([8122574](https://github.com/tractr/stack/commit/8122574544697a29a2acf1aef799fc568fb50be0))
-
-
-
-## [1.53.1](https://github.com/tractr/stack/compare/v1.53.0...v1.53.1) (2022-08-16)
-
-
-### Bug Fixes
-
-* add test coverage to 80% ([#446](https://github.com/tractr/stack/issues/446)) ([04f1857](https://github.com/tractr/stack/commit/04f18577cf177db6024bd3536aa8e7f6fb6199d8))
-
-
-
-# [1.53.0](https://github.com/tractr/stack/compare/v1.52.2...v1.53.0) (2022-08-15)
-
-
-
-## [1.52.2](https://github.com/tractr/stack/compare/v1.52.1...v1.52.2) (2022-08-12)
-
-
-
-## [1.52.1](https://github.com/tractr/stack/compare/v1.52.0...v1.52.1) (2022-08-12)
-
-
-
-# [1.52.0](https://github.com/tractr/stack/compare/v1.51.1...v1.52.0) (2022-08-11)
-
-
-
-## [1.51.1](https://github.com/tractr/stack/compare/v1.51.0...v1.51.1) (2022-08-09)
-
-
-
-# [1.51.0](https://github.com/tractr/stack/compare/v1.50.1...v1.51.0) (2022-08-02)
-
-
-
-## [1.50.1](https://github.com/tractr/stack/compare/v1.50.0...v1.50.1) (2022-07-19)
-
-
-
-# [1.50.0](https://github.com/tractr/stack/compare/v1.49.0...v1.50.0) (2022-07-14)
-
-
-
-# [1.49.0](https://github.com/tractr/stack/compare/v1.48.4...v1.49.0) (2022-07-06)
-
-
-
-## [1.48.4](https://github.com/tractr/stack/compare/v1.48.3...v1.48.4) (2022-07-04)
-
-
-
-## [1.48.3](https://github.com/tractr/stack/compare/v1.48.2...v1.48.3) (2022-07-04)
-
-
-
-## [1.48.2](https://github.com/tractr/stack/compare/v1.48.1...v1.48.2) (2022-06-22)
-
-
-
-## [1.48.1](https://github.com/tractr/stack/compare/v1.48.0...v1.48.1) (2022-06-22)
-
-
-
-# [1.48.0](https://github.com/tractr/stack/compare/v1.47.0...v1.48.0) (2022-06-22)
+* add nestjs-file-storage and angular-file-storage libs ([#149](https://github.com/tractr/stack/issues/149)) ([804c4a6](https://github.com/tractr/stack/commit/804c4a6b1062a087804bfa2abec60db62c816269))
+# [0.2.0](https://github.com/tractr/stack/compare/angular-authentication-0.1.0...angular-authentication-0.2.0) (2021-07-12)
### Features
-
-* update stack's packages ([#444](https://github.com/tractr/stack/issues/444)) ([703410a](https://github.com/tractr/stack/commit/703410afd5a2761095620652f063c292305e4cdc))
-
-
-
-# [1.47.0](https://github.com/tractr/stack/compare/v1.46.3...v1.47.0) (2022-06-07)
-
-
-
-## [1.46.3](https://github.com/tractr/stack/compare/v1.46.2...v1.46.3) (2022-06-06)
-
-
-
-## [1.46.2](https://github.com/tractr/stack/compare/v1.46.1...v1.46.2) (2022-06-06)
-
-
-
-## [1.46.1](https://github.com/tractr/stack/compare/v1.46.0...v1.46.1) (2022-06-06)
-
-
-
-# [1.46.0](https://github.com/tractr/stack/compare/v1.45.5...v1.46.0) (2022-06-02)
-
-
-
-## [1.45.5](https://github.com/tractr/stack/compare/v1.45.4...v1.45.5) (2022-05-31)
-
-
-
-## [1.45.4](https://github.com/tractr/stack/compare/v1.45.3...v1.45.4) (2022-05-30)
-
-
-
-## [1.45.3](https://github.com/tractr/stack/compare/v1.45.2...v1.45.3) (2022-05-25)
-
-
-
-## [1.45.2](https://github.com/tractr/stack/compare/v1.45.1...v1.45.2) (2022-05-18)
-
-
-
-## [1.45.1](https://github.com/tractr/stack/compare/v1.45.0...v1.45.1) (2022-05-18)
-
-
-
-# [1.45.0](https://github.com/tractr/stack/compare/v1.44.0...v1.45.0) (2022-05-17)
-
-
-
-# [1.44.0](https://github.com/tractr/stack/compare/v1.43.16...v1.44.0) (2022-05-16)
-
-
-
-## [1.43.16](https://github.com/tractr/stack/compare/v1.43.15...v1.43.16) (2022-05-16)
-
-
-
-## [1.43.15](https://github.com/tractr/stack/compare/v1.43.14...v1.43.15) (2022-05-11)
-
-
-
-## [1.43.14](https://github.com/tractr/stack/compare/v1.43.13...v1.43.14) (2022-05-10)
-
-
-
-## [1.43.13](https://github.com/tractr/stack/compare/v1.43.12...v1.43.13) (2022-05-03)
-
-
-
-## [1.43.12](https://github.com/tractr/stack/compare/v1.43.11...v1.43.12) (2022-05-03)
-
-
-
-## [1.43.11](https://github.com/tractr/stack/compare/v1.43.10...v1.43.11) (2022-05-02)
-
-
-
-## [1.43.10](https://github.com/tractr/stack/compare/v1.43.9...v1.43.10) (2022-04-28)
-
-
-
-## [1.43.9](https://github.com/tractr/stack/compare/v1.43.8...v1.43.9) (2022-04-14)
-
-
-
-## [1.43.8](https://github.com/tractr/stack/compare/v1.43.7...v1.43.8) (2022-04-12)
-
-
-
-## [1.43.7](https://github.com/tractr/stack/compare/v1.43.6...v1.43.7) (2022-04-11)
-
-
-
-## [1.43.6](https://github.com/tractr/stack/compare/v1.43.5...v1.43.6) (2022-04-08)
-
-
-
-## [1.43.5](https://github.com/tractr/stack/compare/v1.43.4...v1.43.5) (2022-04-07)
-
-
-
-## [1.43.4](https://github.com/tractr/stack/compare/v1.43.3...v1.43.4) (2022-04-06)
-
-
-
-## [1.43.3](https://github.com/tractr/stack/compare/v1.43.2...v1.43.3) (2022-04-06)
-
-
-
-## [1.43.2](https://github.com/tractr/stack/compare/v1.43.1...v1.43.2) (2022-04-06)
-
-
-
-## [1.43.1](https://github.com/tractr/stack/compare/v1.43.0...v1.43.1) (2022-04-06)
-
-
-
-# [1.43.0](https://github.com/tractr/stack/compare/v1.42.1...v1.43.0) (2022-04-05)
-
-
-
-## [1.42.1](https://github.com/tractr/stack/compare/v1.42.0...v1.42.1) (2022-03-15)
-
-
-
-# [1.42.0](https://github.com/tractr/stack/compare/v1.41.0...v1.42.0) (2022-03-03)
-
-
-
-# [1.41.0](https://github.com/tractr/stack/compare/v1.40.0...v1.41.0) (2022-03-03)
-
-
-
-# [1.40.0](https://github.com/tractr/stack/compare/v1.39.6...v1.40.0) (2022-02-28)
-
-
-
-## [1.39.6](https://github.com/tractr/stack/compare/v1.39.5...v1.39.6) (2022-02-23)
-
-
-
-## [1.39.5](https://github.com/tractr/stack/compare/v1.39.4...v1.39.5) (2022-02-23)
-
-
-
-## [1.39.4](https://github.com/tractr/stack/compare/v1.39.3...v1.39.4) (2022-02-22)
-
-
-
-## [1.39.3](https://github.com/tractr/stack/compare/v1.39.2...v1.39.3) (2022-02-22)
-
-
-
-## [1.39.2](https://github.com/tractr/stack/compare/v1.39.1...v1.39.2) (2022-02-22)
-
-
-
-## [1.39.1](https://github.com/tractr/stack/compare/v1.39.0...v1.39.1) (2022-02-19)
-
-
-
-# [1.39.0](https://github.com/tractr/stack/compare/v1.38.0...v1.39.0) (2022-02-18)
-
-
-
-# [1.38.0](https://github.com/tractr/stack/compare/v1.37.1...v1.38.0) (2022-02-17)
-
-
-### Features
-
-* add create hapify workspace command ([#387](https://github.com/tractr/stack/issues/387)) ([98119b9](https://github.com/tractr/stack/commit/98119b9be282b5afcd8bf7ee82af8b677eeaab0a))
-
-
-
-## [1.37.1](https://github.com/tractr/stack/compare/v1.37.0...v1.37.1) (2022-02-17)
-
-
-
-# [1.37.0](https://github.com/tractr/stack/compare/v1.36.3...v1.37.0) (2022-02-16)
-
-
-
-## [1.36.3](https://github.com/tractr/stack/compare/v1.36.2...v1.36.3) (2022-02-11)
-
-
-
-## [1.36.2](https://github.com/tractr/stack/compare/v1.36.1...v1.36.2) (2022-02-10)
-
-
-
-## [1.36.1](https://github.com/tractr/stack/compare/v1.36.0...v1.36.1) (2022-02-09)
-
-
-
-# [1.36.0](https://github.com/tractr/stack/compare/v1.35.0...v1.36.0) (2022-02-08)
-
-
-
-# [1.35.0](https://github.com/tractr/stack/compare/v1.34.0...v1.35.0) (2022-02-08)
-
-
-
-# [1.34.0](https://github.com/tractr/stack/compare/v1.33.0...v1.34.0) (2022-01-31)
-
-
-### Features
-
-* update nx and angular to v13 and prisma to v3 ([#362](https://github.com/tractr/stack/issues/362)) ([7432363](https://github.com/tractr/stack/commit/7432363cdc5f4e7b80bb513f5d9aef1152109d46))
-
-
-
-# [1.33.0](https://github.com/tractr/stack/compare/v1.32.1...v1.33.0) (2022-01-20)
-
-
-
-## [1.32.1](https://github.com/tractr/stack/compare/v1.32.0...v1.32.1) (2022-01-20)
-
-
-
-# [1.32.0](https://github.com/tractr/stack/compare/v1.31.0...v1.32.0) (2022-01-07)
-
-
-
-# [1.31.0](https://github.com/tractr/stack/compare/v1.30.0...v1.31.0) (2021-12-21)
-
-
-
-# [1.30.0](https://github.com/tractr/stack/compare/v1.29.3...v1.30.0) (2021-12-15)
-
-
-
-## [1.29.3](https://github.com/tractr/stack/compare/v1.29.2...v1.29.3) (2021-12-14)
-
-
-
-## [1.29.2](https://github.com/tractr/stack/compare/v1.29.1...v1.29.2) (2021-12-14)
-
-
-
-## [1.29.1](https://github.com/tractr/stack/compare/v1.29.0...v1.29.1) (2021-12-09)
-
-
-
-# [1.29.0](https://github.com/tractr/stack/compare/v1.28.5...v1.29.0) (2021-12-07)
-
-
-### Features
-
-* update angular authentication with dto check ([#324](https://github.com/tractr/stack/issues/324)) ([078c93a](https://github.com/tractr/stack/commit/078c93a54cc778884b2323be392a66f40e0156a0))
-
-
-
-## [1.28.5](https://github.com/tractr/stack/compare/v1.28.4...v1.28.5) (2021-12-06)
-
-
-
-## [1.28.4](https://github.com/tractr/stack/compare/v1.28.3...v1.28.4) (2021-12-03)
-
-
-### Bug Fixes
-
-* remove User validate nested from authentication options dto ([#321](https://github.com/tractr/stack/issues/321)) ([fc3d8cf](https://github.com/tractr/stack/commit/fc3d8cfae3cf88f1e5ba0dbd38f4753e7e7830e5))
-
-
-
-## [1.28.3](https://github.com/tractr/stack/compare/v1.28.2...v1.28.3) (2021-12-03)
-
-
-### Bug Fixes
-
-* use typeof instead of the dto to type the angular injection token ([#320](https://github.com/tractr/stack/issues/320)) ([4653bdf](https://github.com/tractr/stack/commit/4653bdfe66d458949cea94a61bf615ac703a4cd4))
-
-
-
-## [1.28.2](https://github.com/tractr/stack/compare/v1.28.1...v1.28.2) (2021-12-03)
-
-
-
-## [1.28.1](https://github.com/tractr/stack/compare/v1.28.0...v1.28.1) (2021-12-02)
-
-
-
-# [1.28.0](https://github.com/tractr/stack/compare/v1.27.2...v1.28.0) (2021-12-02)
-
-
-
-## [1.27.2](https://github.com/tractr/stack/compare/v1.27.1...v1.27.2) (2021-12-01)
-
-
-
-## [1.27.1](https://github.com/tractr/stack/compare/v1.27.0...v1.27.1) (2021-11-30)
-
-
-
-# [1.27.0](https://github.com/tractr/stack/compare/v1.26.0...v1.27.0) (2021-11-30)
-
-
-### Features
-
-* remove generated code from nestjs authentication and angular authentication package ([#312](https://github.com/tractr/stack/issues/312)) ([4fa7bfa](https://github.com/tractr/stack/commit/4fa7bfa536d1accb483fa8b83f93c9395de5e1e0)), closes [#313](https://github.com/tractr/stack/issues/313)
-
-
-
-# [1.26.0](https://github.com/tractr/stack/compare/v1.25.0...v1.26.0) (2021-11-30)
-
-
-
-# [1.25.0](https://github.com/tractr/stack/compare/v1.24.0...v1.25.0) (2021-11-29)
-
-
-
-# [1.24.0](https://github.com/tractr/stack/compare/v1.23.2...v1.24.0) (2021-11-18)
-
-
-
-## [1.23.2](https://github.com/tractr/stack/compare/v1.23.1...v1.23.2) (2021-11-16)
-
-
-
-## [1.23.1](https://github.com/tractr/stack/compare/v1.23.0...v1.23.1) (2021-11-09)
-
-
-
-# [1.23.0](https://github.com/tractr/stack/compare/v1.22.4...v1.23.0) (2021-11-03)
-
-
-
-## [1.22.4](https://github.com/tractr/stack/compare/v1.22.3...v1.22.4) (2021-10-29)
-
-
-
-## [1.22.3](https://github.com/tractr/stack/compare/v1.22.2...v1.22.3) (2021-10-28)
-
-
-
-## [1.22.2](https://github.com/tractr/stack/compare/v1.22.1...v1.22.2) (2021-10-28)
-
-
-
-## [1.22.1](https://github.com/tractr/stack/compare/v1.22.0...v1.22.1) (2021-10-27)
-
-
-
-# [1.22.0](https://github.com/tractr/stack/compare/v1.21.4...v1.22.0) (2021-10-19)
-
-
-
-## [1.21.4](https://github.com/tractr/stack/compare/v1.21.3...v1.21.4) (2021-10-15)
-
-
-
-## [1.21.3](https://github.com/tractr/stack/compare/v1.21.2...v1.21.3) (2021-10-15)
-
-
-
-## [1.21.2](https://github.com/tractr/stack/compare/v1.21.1...v1.21.2) (2021-10-15)
-
-
-
-## [1.21.1](https://github.com/tractr/stack/compare/v1.21.0...v1.21.1) (2021-10-13)
-
-
-
-# [1.21.0](https://github.com/tractr/stack/compare/v1.20.1...v1.21.0) (2021-10-13)
-
-
-
-## [0.6.4](https://github.com/tractr/stack/compare/angular-authentication-0.6.3...angular-authentication-0.6.4) (2021-09-28)
-
-
-### Bug Fixes
-
-* **angular-authentication:** fix session in error ([#273](https://github.com/tractr/stack/issues/273)) ([70d45c6](https://github.com/tractr/stack/commit/70d45c669eebe37c445fee0d26c065e98bbb0f02))
-
-
-
-## [0.6.3](https://github.com/tractr/stack/compare/angular-authentication-0.6.2...angular-authentication-0.6.3) (2021-08-10)
-
-
-### Bug Fixes
-
-* angular authentication add password service in providers ([#225](https://github.com/tractr/stack/issues/225)) ([c261630](https://github.com/tractr/stack/commit/c2616304048ad908cbfcc4ab4e0c3a47c351b1d5))
-
-
-
-## [0.6.2](https://github.com/tractr/stack/compare/angular-authentication-0.6.1...angular-authentication-0.6.2) (2021-08-06)
-
-
-### Bug Fixes
-
-* do not fail when the fetch user fail that cause the whole rx chain to complete with error ([#218](https://github.com/tractr/stack/issues/218)) ([ce6d04f](https://github.com/tractr/stack/commit/ce6d04f702b7b9f9b88e2fdec0ea403bb9f3e9ba))
-
-
-
-## [0.6.1](https://github.com/tractr/stack/compare/angular-authentication-0.6.0...angular-authentication-0.6.1) (2021-08-05)
-
-
-### Bug Fixes
-
-* use the spread operator to decuonstruct correctly the options arguments ([#217](https://github.com/tractr/stack/issues/217)) ([3a6d15c](https://github.com/tractr/stack/commit/3a6d15c751b8fecc9b6fc091e44af1688cb22f2f))
-
-
-
-# [0.6.0](https://github.com/tractr/stack/compare/angular-authentication-0.5.0...angular-authentication-0.6.0) (2021-07-30)
-
-
-
-# [0.5.0](https://github.com/tractr/stack/compare/angular-authentication-0.4.3...angular-authentication-0.5.0) (2021-07-28)
-
-
-### Features
-
-* add casl packages to the stack to get a right policy via hapify ([#184](https://github.com/tractr/stack/issues/184)) ([cc241c1](https://github.com/tractr/stack/commit/cc241c1f3e737febadb5ecb90113732be8088d76))
-* add password recovery to the authentication process ([#191](https://github.com/tractr/stack/issues/191)) ([2f33209](https://github.com/tractr/stack/commit/2f332091d96728e8e407a20b781e9816344bca7b))
-
-
-
-## [0.4.3](https://github.com/tractr/stack/compare/angular-authentication-0.4.2...angular-authentication-0.4.3) (2021-07-21)
-
-
-### Bug Fixes
-
-* remove the http dependencies from angular config service that was causing circular deps ([#198](https://github.com/tractr/stack/issues/198)) ([c52152a](https://github.com/tractr/stack/commit/c52152a061fcd54bed3a36931c0cf88f05310d8d))
-
-
-
-## [0.4.2](https://github.com/tractr/stack/compare/angular-authentication-0.4.1...angular-authentication-0.4.2) (2021-07-21)
-
-
-### Bug Fixes
-
-* change module options factory typing ([#196](https://github.com/tractr/stack/issues/196)) ([9a55c71](https://github.com/tractr/stack/commit/9a55c71bd516b0812c560aecd91d7d2ebdb6c533))
-
-
-
-## [0.4.1](https://github.com/tractr/stack/compare/angular-authentication-0.4.0...angular-authentication-0.4.1) (2021-07-19)
-
-
-### Bug Fixes
-
-* update packages to get a module options factory that can set defaults & validate front & back ([#192](https://github.com/tractr/stack/issues/192)) ([3975d36](https://github.com/tractr/stack/commit/3975d3690f82221ce1f207acff0ae3f63346eca5))
-
-
-
-# [0.4.0](https://github.com/tractr/stack/compare/angular-authentication-0.3.0...angular-authentication-0.4.0) (2021-07-15)
-
-
-### Features
-
-* **angular-authentication:** fix guard redirect ([#189](https://github.com/tractr/stack/issues/189)) ([346455e](https://github.com/tractr/stack/commit/346455e064eeaff6c536a672fa60179897dab91f))
-
-
-
-# [0.3.0](https://github.com/tractr/stack/compare/angular-authentication-0.2.1...angular-authentication-0.3.0) (2021-07-13)
-
-
-### Features
-
-* add nestjs-file-storage and angular-file-storage libs ([#149](https://github.com/tractr/stack/issues/149)) ([804c4a6](https://github.com/tractr/stack/commit/804c4a6b1062a087804bfa2abec60db62c816269))
-
-
-
-## [0.2.1](https://github.com/tractr/stack/compare/angular-authentication-0.2.0...angular-authentication-0.2.1) (2021-07-13)
-
-
-### Bug Fixes
-
-* remove all reference to [@generated](https://github.com/generated) from the generated files and only use the relative paths ([#172](https://github.com/tractr/stack/issues/172)) ([8117df7](https://github.com/tractr/stack/commit/8117df7e58fd3ef4b0e9e051d1235c19b361149b))
-
-
-
-# [0.2.0](https://github.com/tractr/stack/compare/angular-authentication-0.1.0...angular-authentication-0.2.0) (2021-07-12)
-
-
-### Features
-
-* update all package json dependencies ([#167](https://github.com/tractr/stack/issues/167)) ([aee9606](https://github.com/tractr/stack/commit/aee96067b70286145162f57184a37f25dce1d274))
-
-
-
-# 0.1.0 (2021-07-12)
-
-
-### Features
-
-* add angular authentication package to the stack ([#156](https://github.com/tractr/stack/issues/156)) ([f23d2d8](https://github.com/tractr/stack/commit/f23d2d8691b84fed688cbc67c94457080f5719bd))
diff --git a/libs/angular/authentication/package.json b/libs/angular/authentication/package.json
index 03584a672..90c575830 100644
--- a/libs/angular/authentication/package.json
+++ b/libs/angular/authentication/package.json
@@ -1,6 +1,6 @@
{
"name": "@trxn/angular-authentication",
- "version": "2.0.13",
+ "version": "2.1.0-next.1",
"repository": {
"type": "git",
"url": "https://github.com/tractr/traxion"
diff --git a/libs/angular/casl/CHANGELOG.md b/libs/angular/casl/CHANGELOG.md
index 023c0163f..97bb74375 100644
--- a/libs/angular/casl/CHANGELOG.md
+++ b/libs/angular/casl/CHANGELOG.md
@@ -2,6 +2,14 @@
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
+# [2.1.0-next.1](https://github.com/tractr/traxion/compare/v2.1.0-next.0...v2.1.0-next.1) (2023-02-27)
+
+
+
+# [2.1.0-next.0](https://github.com/tractr/traxion/compare/v2.0.13...v2.1.0-next.0) (2023-02-27)
+
+
+
## [2.0.13](https://github.com/tractr/traxion/compare/v2.0.12...v2.0.13) (2023-02-24)
diff --git a/libs/angular/casl/package.json b/libs/angular/casl/package.json
index f012584a8..7a94f3c05 100644
--- a/libs/angular/casl/package.json
+++ b/libs/angular/casl/package.json
@@ -1,6 +1,6 @@
{
"name": "@trxn/angular-casl",
- "version": "2.0.13",
+ "version": "2.1.0-next.1",
"repository": {
"type": "git",
"url": "https://github.com/tractr/traxion"
diff --git a/libs/angular/components/CHANGELOG.md b/libs/angular/components/CHANGELOG.md
index 82e68a8ec..c0461a637 100644
--- a/libs/angular/components/CHANGELOG.md
+++ b/libs/angular/components/CHANGELOG.md
@@ -2,6 +2,35 @@
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
+# [2.1.0-next.1](https://github.com/tractr/traxion/compare/v2.1.0-next.0...v2.1.0-next.1) (2023-02-27)
+
+
+
+# [2.1.0-next.0](https://github.com/tractr/traxion/compare/v2.0.13...v2.1.0-next.0) (2023-02-27)
+
+
+
+## [2.0.11-next.3](https://github.com/tractr/traxion/compare/v2.0.11-next.2...v2.0.11-next.3) (2023-02-22)
+
+
+
+## [2.0.11-next.2](https://github.com/tractr/traxion/compare/v2.0.11-next.1...v2.0.11-next.2) (2023-02-22)
+
+
+
+## [2.0.11-next.1](https://github.com/tractr/traxion/compare/v2.0.11-next.0...v2.0.11-next.1) (2023-02-22)
+
+
+
+## [2.0.11-next.0](https://github.com/tractr/traxion/compare/v2.0.10...v2.0.11-next.0) (2023-02-22)
+
+
+### Features
+
+* clean authentication modules ([99b7db6](https://github.com/tractr/traxion/commit/99b7db69cc4f885ac885d147043003448895d66d))
+
+
+
## [2.0.13](https://github.com/tractr/traxion/compare/v2.0.12...v2.0.13) (2023-02-24)
diff --git a/libs/angular/components/package.json b/libs/angular/components/package.json
index d24a55fbc..64d4d652c 100644
--- a/libs/angular/components/package.json
+++ b/libs/angular/components/package.json
@@ -1,6 +1,6 @@
{
"name": "@trxn/angular-components",
- "version": "2.0.13",
+ "version": "2.1.0-next.1",
"repository": {
"type": "git",
"url": "https://github.com/tractr/traxion"
diff --git a/libs/angular/components/src/lib/model/model.module.ts b/libs/angular/components/src/lib/model/model.module.ts
index fe9e49b04..bf46ac956 100644
--- a/libs/angular/components/src/lib/model/model.module.ts
+++ b/libs/angular/components/src/lib/model/model.module.ts
@@ -1,7 +1,7 @@
import { NgModule } from '@angular/core';
-import { SelectModule } from '../select/select.module';
import { ModelSelectComponent } from './select/select.component';
+import { SelectModule } from '../select/select.module';
import { AngularToolsModule } from '@trxn/angular-tools';
diff --git a/libs/angular/config/CHANGELOG.md b/libs/angular/config/CHANGELOG.md
index 4790490e4..4db4a485b 100644
--- a/libs/angular/config/CHANGELOG.md
+++ b/libs/angular/config/CHANGELOG.md
@@ -2,6 +2,14 @@
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
+# [2.1.0-next.1](https://github.com/tractr/traxion/compare/v2.1.0-next.0...v2.1.0-next.1) (2023-02-27)
+
+
+
+# [2.1.0-next.0](https://github.com/tractr/traxion/compare/v2.0.13...v2.1.0-next.0) (2023-02-27)
+
+
+
## [2.0.13](https://github.com/tractr/traxion/compare/v2.0.12...v2.0.13) (2023-02-24)
diff --git a/libs/angular/config/package.json b/libs/angular/config/package.json
index 1c781b6f7..1ab69bbb1 100644
--- a/libs/angular/config/package.json
+++ b/libs/angular/config/package.json
@@ -1,6 +1,6 @@
{
"name": "@trxn/angular-config",
- "version": "2.0.13",
+ "version": "2.1.0-next.1",
"repository": {
"type": "git",
"url": "https://github.com/tractr/traxion"
diff --git a/libs/angular/file-storage/CHANGELOG.md b/libs/angular/file-storage/CHANGELOG.md
index f507fc1f8..66fa0de24 100644
--- a/libs/angular/file-storage/CHANGELOG.md
+++ b/libs/angular/file-storage/CHANGELOG.md
@@ -2,6 +2,14 @@
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
+# [2.1.0-next.1](https://github.com/tractr/traxion/compare/v2.1.0-next.0...v2.1.0-next.1) (2023-02-27)
+
+
+
+# [2.1.0-next.0](https://github.com/tractr/traxion/compare/v2.0.13...v2.1.0-next.0) (2023-02-27)
+
+
+
## [2.0.13](https://github.com/tractr/traxion/compare/v2.0.12...v2.0.13) (2023-02-24)
diff --git a/libs/angular/file-storage/package.json b/libs/angular/file-storage/package.json
index 3a6169cd8..277be62ab 100644
--- a/libs/angular/file-storage/package.json
+++ b/libs/angular/file-storage/package.json
@@ -1,6 +1,6 @@
{
"name": "@trxn/angular-file-storage",
- "version": "2.0.13",
+ "version": "2.1.0-next.1",
"repository": {
"type": "git",
"url": "https://github.com/tractr/traxion"
diff --git a/libs/angular/form/CHANGELOG.md b/libs/angular/form/CHANGELOG.md
index 247dcdf91..d4ecd85f1 100644
--- a/libs/angular/form/CHANGELOG.md
+++ b/libs/angular/form/CHANGELOG.md
@@ -2,6 +2,14 @@
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
+# [2.1.0-next.1](https://github.com/tractr/traxion/compare/v2.1.0-next.0...v2.1.0-next.1) (2023-02-27)
+
+
+
+# [2.1.0-next.0](https://github.com/tractr/traxion/compare/v2.0.13...v2.1.0-next.0) (2023-02-27)
+
+
+
## [2.0.13](https://github.com/tractr/traxion/compare/v2.0.12...v2.0.13) (2023-02-24)
diff --git a/libs/angular/form/package.json b/libs/angular/form/package.json
index 72a15a3fe..243266b63 100644
--- a/libs/angular/form/package.json
+++ b/libs/angular/form/package.json
@@ -1,6 +1,6 @@
{
"name": "@trxn/angular-form",
- "version": "2.0.13",
+ "version": "2.1.0-next.1",
"repository": {
"type": "git",
"url": "https://github.com/tractr/traxion"
diff --git a/libs/angular/tools/CHANGELOG.md b/libs/angular/tools/CHANGELOG.md
index f7bff05d9..d0563e523 100644
--- a/libs/angular/tools/CHANGELOG.md
+++ b/libs/angular/tools/CHANGELOG.md
@@ -2,6 +2,14 @@
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
+# [2.1.0-next.1](https://github.com/tractr/traxion/compare/v2.1.0-next.0...v2.1.0-next.1) (2023-02-27)
+
+
+
+# [2.1.0-next.0](https://github.com/tractr/traxion/compare/v2.0.13...v2.1.0-next.0) (2023-02-27)
+
+
+
## [2.0.13](https://github.com/tractr/traxion/compare/v2.0.12...v2.0.13) (2023-02-24)
diff --git a/libs/angular/tools/package.json b/libs/angular/tools/package.json
index a71c32d25..792fc742c 100644
--- a/libs/angular/tools/package.json
+++ b/libs/angular/tools/package.json
@@ -1,6 +1,6 @@
{
"name": "@trxn/angular-tools",
- "version": "2.0.13",
+ "version": "2.1.0-next.1",
"description": "Tools for angular application",
"repository": {
"type": "git",
diff --git a/libs/common/CHANGELOG.md b/libs/common/CHANGELOG.md
index 360cc531c..fd97f9af1 100644
--- a/libs/common/CHANGELOG.md
+++ b/libs/common/CHANGELOG.md
@@ -2,6 +2,35 @@
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
+# [2.1.0-next.1](https://github.com/tractr/traxion/compare/v2.1.0-next.0...v2.1.0-next.1) (2023-02-27)
+
+
+
+# [2.1.0-next.0](https://github.com/tractr/traxion/compare/v2.0.13...v2.1.0-next.0) (2023-02-27)
+
+
+
+## [2.0.11-next.3](https://github.com/tractr/traxion/compare/v2.0.11-next.2...v2.0.11-next.3) (2023-02-22)
+
+
+
+## [2.0.11-next.2](https://github.com/tractr/traxion/compare/v2.0.11-next.1...v2.0.11-next.2) (2023-02-22)
+
+
+
+## [2.0.11-next.1](https://github.com/tractr/traxion/compare/v2.0.11-next.0...v2.0.11-next.1) (2023-02-22)
+
+
+
+## [2.0.11-next.0](https://github.com/tractr/traxion/compare/v2.0.10...v2.0.11-next.0) (2023-02-22)
+
+
+### Features
+
+* clean authentication modules ([99b7db6](https://github.com/tractr/traxion/commit/99b7db69cc4f885ac885d147043003448895d66d))
+
+
+
## [2.0.13](https://github.com/tractr/traxion/compare/v2.0.12...v2.0.13) (2023-02-24)
diff --git a/libs/common/package.json b/libs/common/package.json
index 7cc6a63b5..1d35b36ac 100644
--- a/libs/common/package.json
+++ b/libs/common/package.json
@@ -1,6 +1,6 @@
{
"name": "@trxn/common",
- "version": "2.0.13",
+ "version": "2.1.0-next.1",
"description": "Common module for back and front",
"repository": {
"type": "git",
diff --git a/libs/common/src/lib/validator-transformer/validators/bool-filter-validate.ts b/libs/common/src/lib/validator-transformer/validators/bool-filter-validate.ts
index 559f8cb42..380589a98 100644
--- a/libs/common/src/lib/validator-transformer/validators/bool-filter-validate.ts
+++ b/libs/common/src/lib/validator-transformer/validators/bool-filter-validate.ts
@@ -1,9 +1,9 @@
import { isBooleanString, isIn } from 'class-validator';
import { isBoolean } from 'lodash';
+import { CustomValidate } from './custom-validate';
import { ArrayFilterProps, BoolFilterProps } from '../../constants';
import { transformStringToArray } from '../../helpers';
-import { CustomValidate } from './custom-validate';
/**
* Accept a field string and return a boolean indicating if the field is a boolean string and filter type
diff --git a/libs/common/src/lib/validator-transformer/validators/date-time-filter-validate.ts b/libs/common/src/lib/validator-transformer/validators/date-time-filter-validate.ts
index 9b2073b41..2941c6c0d 100644
--- a/libs/common/src/lib/validator-transformer/validators/date-time-filter-validate.ts
+++ b/libs/common/src/lib/validator-transformer/validators/date-time-filter-validate.ts
@@ -1,8 +1,8 @@
import { isDate, isDateString, isIn } from 'class-validator';
+import { CustomValidate } from './custom-validate';
import { ArrayFilterProps, DateTimeFilterProps } from '../../constants';
import { transformStringToArray } from '../../helpers';
-import { CustomValidate } from './custom-validate';
/**
* Accept a field string and return a boolean indicating if the field is an integer string and filter type
diff --git a/libs/common/src/lib/validator-transformer/validators/enum-filter-validate.ts b/libs/common/src/lib/validator-transformer/validators/enum-filter-validate.ts
index 044700932..60f8fa373 100644
--- a/libs/common/src/lib/validator-transformer/validators/enum-filter-validate.ts
+++ b/libs/common/src/lib/validator-transformer/validators/enum-filter-validate.ts
@@ -1,8 +1,8 @@
import { isIn } from 'class-validator';
+import { CustomValidate } from './custom-validate';
import { ArrayFilterProps, EnumFilterProps } from '../../constants';
import { transformStringToArray } from '../../helpers';
-import { CustomValidate } from './custom-validate';
/**
* Accept a field string and return a boolean indicating if the field is string and filter type
diff --git a/libs/common/src/lib/validator-transformer/validators/json-filter-validate.spec.ts b/libs/common/src/lib/validator-transformer/validators/json-filter-validate.spec.ts
index 0818bfea5..5ef0728ae 100644
--- a/libs/common/src/lib/validator-transformer/validators/json-filter-validate.spec.ts
+++ b/libs/common/src/lib/validator-transformer/validators/json-filter-validate.spec.ts
@@ -2,8 +2,8 @@
/* eslint-disable max-classes-per-file */
import { validate } from 'class-validator';
-import { JsonArray, JsonObject } from '../../interfaces';
import { JsonFilterValidate } from './json-filter-validate';
+import { JsonArray, JsonObject } from '../../interfaces';
describe('JsonFilterValidate decorator', () => {
// Class to test the JsonFilterValidate decorator
diff --git a/libs/common/src/lib/validator-transformer/validators/json-filter-validate.ts b/libs/common/src/lib/validator-transformer/validators/json-filter-validate.ts
index 012f3a16b..92bf7e852 100644
--- a/libs/common/src/lib/validator-transformer/validators/json-filter-validate.ts
+++ b/libs/common/src/lib/validator-transformer/validators/json-filter-validate.ts
@@ -1,8 +1,8 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { isIn, isObject } from 'class-validator';
-import { JsonFilterProps } from '../../constants';
import { CustomValidate } from './custom-validate';
+import { JsonFilterProps } from '../../constants';
/**
* Accept a field string and return a boolean indicating if the field is an object string with filter type
diff --git a/libs/common/src/lib/validator-transformer/validators/number-filter-validate.ts b/libs/common/src/lib/validator-transformer/validators/number-filter-validate.ts
index 60076cf62..e0a53e4c9 100644
--- a/libs/common/src/lib/validator-transformer/validators/number-filter-validate.ts
+++ b/libs/common/src/lib/validator-transformer/validators/number-filter-validate.ts
@@ -1,8 +1,8 @@
import { isIn, isNumber, isNumberString } from 'class-validator';
+import { CustomValidate } from './custom-validate';
import { ArrayFilterProps, NumberFilterProps } from '../../constants';
import { transformStringToArray } from '../../helpers';
-import { CustomValidate } from './custom-validate';
/**
* Accept a field string and return a boolean indicating if the field is a boolean string and filter type
diff --git a/libs/common/src/lib/validator-transformer/validators/string-filter-validate.ts b/libs/common/src/lib/validator-transformer/validators/string-filter-validate.ts
index 064a31001..44ec852f1 100644
--- a/libs/common/src/lib/validator-transformer/validators/string-filter-validate.ts
+++ b/libs/common/src/lib/validator-transformer/validators/string-filter-validate.ts
@@ -1,8 +1,8 @@
import { isIn, isString } from 'class-validator';
+import { CustomValidate } from './custom-validate';
import { ArrayFilterProps, StringFilterProps } from '../../constants';
import { transformStringToArray } from '../../helpers';
-import { CustomValidate } from './custom-validate';
/**
* Accept a field string and return a boolean indicating if the field is string and filter type
diff --git a/libs/config/client/CHANGELOG.md b/libs/config/client/CHANGELOG.md
index 2419e060f..d2fcb6d11 100644
--- a/libs/config/client/CHANGELOG.md
+++ b/libs/config/client/CHANGELOG.md
@@ -2,6 +2,14 @@
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
+# [2.1.0-next.1](https://github.com/tractr/traxion/compare/v2.1.0-next.0...v2.1.0-next.1) (2023-02-27)
+
+
+
+# [2.1.0-next.0](https://github.com/tractr/traxion/compare/v2.0.13...v2.1.0-next.0) (2023-02-27)
+
+
+
## [2.0.13](https://github.com/tractr/traxion/compare/v2.0.12...v2.0.13) (2023-02-24)
diff --git a/libs/config/client/package.json b/libs/config/client/package.json
index 478b1785a..dee6ef24b 100644
--- a/libs/config/client/package.json
+++ b/libs/config/client/package.json
@@ -1,6 +1,6 @@
{
"name": "@trxn/client-config",
- "version": "2.0.13",
+ "version": "2.1.0-next.1",
"repository": {
"type": "git",
"url": "https://github.com/tractr/traxion.git"
diff --git a/libs/config/commit/CHANGELOG.md b/libs/config/commit/CHANGELOG.md
index 0a932a9e6..4123daf59 100644
--- a/libs/config/commit/CHANGELOG.md
+++ b/libs/config/commit/CHANGELOG.md
@@ -2,6 +2,14 @@
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
+# [2.1.0-next.1](https://github.com/tractr/traxion/compare/v2.1.0-next.0...v2.1.0-next.1) (2023-02-27)
+
+
+
+# [2.1.0-next.0](https://github.com/tractr/traxion/compare/v2.0.13...v2.1.0-next.0) (2023-02-27)
+
+
+
## [2.0.13](https://github.com/tractr/traxion/compare/v2.0.12...v2.0.13) (2023-02-24)
diff --git a/libs/config/commit/package.json b/libs/config/commit/package.json
index 81c30cb92..eee78fb0f 100644
--- a/libs/config/commit/package.json
+++ b/libs/config/commit/package.json
@@ -1,6 +1,6 @@
{
"name": "@trxn/commit-config",
- "version": "2.0.13",
+ "version": "2.1.0-next.1",
"repository": {
"type": "git",
"url": "https://github.com/tractr/traxion.git"
diff --git a/libs/config/eslint/CHANGELOG.md b/libs/config/eslint/CHANGELOG.md
index 0d6841e9a..776e22e7b 100644
--- a/libs/config/eslint/CHANGELOG.md
+++ b/libs/config/eslint/CHANGELOG.md
@@ -2,6 +2,14 @@
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
+# [2.1.0-next.1](https://github.com/tractr/traxion/compare/v2.1.0-next.0...v2.1.0-next.1) (2023-02-27)
+
+
+
+# [2.1.0-next.0](https://github.com/tractr/traxion/compare/v2.0.13...v2.1.0-next.0) (2023-02-27)
+
+
+
## [2.0.13](https://github.com/tractr/traxion/compare/v2.0.12...v2.0.13) (2023-02-24)
diff --git a/libs/config/eslint/package.json b/libs/config/eslint/package.json
index 2dfcb0249..b4cd8faac 100644
--- a/libs/config/eslint/package.json
+++ b/libs/config/eslint/package.json
@@ -1,6 +1,6 @@
{
"name": "@trxn/eslint-config",
- "version": "2.0.13",
+ "version": "2.1.0-next.1",
"repository": {
"type": "git",
"url": "https://github.com/tractr/traxion.git"
diff --git a/libs/config/hapify/CHANGELOG.md b/libs/config/hapify/CHANGELOG.md
index 052376298..c08c232ca 100644
--- a/libs/config/hapify/CHANGELOG.md
+++ b/libs/config/hapify/CHANGELOG.md
@@ -2,6 +2,14 @@
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
+# [2.1.0-next.1](https://github.com/tractr/traxion/compare/v2.1.0-next.0...v2.1.0-next.1) (2023-02-27)
+
+
+
+# [2.1.0-next.0](https://github.com/tractr/traxion/compare/v2.0.13...v2.1.0-next.0) (2023-02-27)
+
+
+
## [2.0.13](https://github.com/tractr/traxion/compare/v2.0.12...v2.0.13) (2023-02-24)
diff --git a/libs/config/hapify/package.json b/libs/config/hapify/package.json
index a455978c7..6acc43483 100644
--- a/libs/config/hapify/package.json
+++ b/libs/config/hapify/package.json
@@ -1,6 +1,6 @@
{
"name": "@trxn/hapify-config",
- "version": "2.0.13",
+ "version": "2.1.0-next.1",
"repository": {
"type": "git",
"url": "https://github.com/tractr/traxion.git"
diff --git a/libs/config/prettier/CHANGELOG.md b/libs/config/prettier/CHANGELOG.md
index b983b7878..acec90aa4 100644
--- a/libs/config/prettier/CHANGELOG.md
+++ b/libs/config/prettier/CHANGELOG.md
@@ -2,6 +2,14 @@
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
+# [2.1.0-next.1](https://github.com/tractr/traxion/compare/v2.1.0-next.0...v2.1.0-next.1) (2023-02-27)
+
+
+
+# [2.1.0-next.0](https://github.com/tractr/traxion/compare/v2.0.13...v2.1.0-next.0) (2023-02-27)
+
+
+
## [2.0.13](https://github.com/tractr/traxion/compare/v2.0.12...v2.0.13) (2023-02-24)
diff --git a/libs/config/prettier/package.json b/libs/config/prettier/package.json
index 067948462..765609e62 100644
--- a/libs/config/prettier/package.json
+++ b/libs/config/prettier/package.json
@@ -1,6 +1,6 @@
{
"name": "@trxn/prettier-config",
- "version": "2.0.13",
+ "version": "2.1.0-next.1",
"repository": {
"type": "git",
"url": "https://github.com/tractr/traxion.git"
diff --git a/libs/generated/angular-rext-client/CHANGELOG.md b/libs/generated/angular-rext-client/CHANGELOG.md
index 957dc0ebe..0a6907253 100644
--- a/libs/generated/angular-rext-client/CHANGELOG.md
+++ b/libs/generated/angular-rext-client/CHANGELOG.md
@@ -2,6 +2,14 @@
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
+# [2.1.0-next.1](https://github.com/tractr/traxion/compare/v2.1.0-next.0...v2.1.0-next.1) (2023-02-27)
+
+
+
+# [2.1.0-next.0](https://github.com/tractr/traxion/compare/v2.0.13...v2.1.0-next.0) (2023-02-27)
+
+
+
## [2.0.13](https://github.com/tractr/traxion/compare/v2.0.12...v2.0.13) (2023-02-24)
diff --git a/libs/generated/angular-rext-client/package.json b/libs/generated/angular-rext-client/package.json
index 48909da05..600cb7fbf 100644
--- a/libs/generated/angular-rext-client/package.json
+++ b/libs/generated/angular-rext-client/package.json
@@ -1,6 +1,6 @@
{
"name": "@trxn/generated-angular-rext-client",
- "version": "2.0.13",
+ "version": "2.1.0-next.1",
"dependencies": {
"tslib": "^2.3.1"
},
diff --git a/libs/generated/casl/CHANGELOG.md b/libs/generated/casl/CHANGELOG.md
index 1c72d883f..fe735f253 100644
--- a/libs/generated/casl/CHANGELOG.md
+++ b/libs/generated/casl/CHANGELOG.md
@@ -2,6 +2,14 @@
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
+# [2.1.0-next.1](https://github.com/tractr/traxion/compare/v2.1.0-next.0...v2.1.0-next.1) (2023-02-27)
+
+
+
+# [2.1.0-next.0](https://github.com/tractr/traxion/compare/v2.0.13...v2.1.0-next.0) (2023-02-27)
+
+
+
## [2.0.13](https://github.com/tractr/traxion/compare/v2.0.12...v2.0.13) (2023-02-24)
diff --git a/libs/generated/casl/package.json b/libs/generated/casl/package.json
index 7d70f3f69..2eda9c4d4 100644
--- a/libs/generated/casl/package.json
+++ b/libs/generated/casl/package.json
@@ -1,6 +1,6 @@
{
"name": "@trxn/generated-casl",
- "version": "2.0.13",
+ "version": "2.1.0-next.1",
"dependencies": {
"tslib": "^2.3.1"
},
diff --git a/libs/generated/dbml/CHANGELOG.md b/libs/generated/dbml/CHANGELOG.md
index f13664c50..e9b799a11 100644
--- a/libs/generated/dbml/CHANGELOG.md
+++ b/libs/generated/dbml/CHANGELOG.md
@@ -2,6 +2,14 @@
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
+# [2.1.0-next.1](https://github.com/tractr/traxion/compare/v2.1.0-next.0...v2.1.0-next.1) (2023-02-27)
+
+
+
+# [2.1.0-next.0](https://github.com/tractr/traxion/compare/v2.0.13...v2.1.0-next.0) (2023-02-27)
+
+
+
## [2.0.13](https://github.com/tractr/traxion/compare/v2.0.12...v2.0.13) (2023-02-24)
diff --git a/libs/generated/dbml/package.json b/libs/generated/dbml/package.json
index 8a0ff4f07..e6b91e91e 100644
--- a/libs/generated/dbml/package.json
+++ b/libs/generated/dbml/package.json
@@ -1,4 +1,4 @@
{
"name": "@trxn/generated-dbml",
- "version": "2.0.13"
+ "version": "2.1.0-next.1"
}
diff --git a/libs/generated/models/CHANGELOG.md b/libs/generated/models/CHANGELOG.md
index f13664c50..e9b799a11 100644
--- a/libs/generated/models/CHANGELOG.md
+++ b/libs/generated/models/CHANGELOG.md
@@ -2,6 +2,14 @@
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
+# [2.1.0-next.1](https://github.com/tractr/traxion/compare/v2.1.0-next.0...v2.1.0-next.1) (2023-02-27)
+
+
+
+# [2.1.0-next.0](https://github.com/tractr/traxion/compare/v2.0.13...v2.1.0-next.0) (2023-02-27)
+
+
+
## [2.0.13](https://github.com/tractr/traxion/compare/v2.0.12...v2.0.13) (2023-02-24)
diff --git a/libs/generated/models/package.json b/libs/generated/models/package.json
index 47aa8111b..3441688e8 100644
--- a/libs/generated/models/package.json
+++ b/libs/generated/models/package.json
@@ -1,4 +1,4 @@
{
"name": "@trxn/generated-models",
- "version": "2.0.13"
+ "version": "2.1.0-next.1"
}
diff --git a/libs/generated/nestjs-graphql/CHANGELOG.md b/libs/generated/nestjs-graphql/CHANGELOG.md
index 1d0eada1c..95133946a 100644
--- a/libs/generated/nestjs-graphql/CHANGELOG.md
+++ b/libs/generated/nestjs-graphql/CHANGELOG.md
@@ -2,6 +2,14 @@
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
+# [2.1.0-next.1](https://github.com/tractr/traxion/compare/v2.1.0-next.0...v2.1.0-next.1) (2023-02-27)
+
+
+
+# [2.1.0-next.0](https://github.com/tractr/traxion/compare/v2.0.13...v2.1.0-next.0) (2023-02-27)
+
+
+
## [2.0.13](https://github.com/tractr/traxion/compare/v2.0.12...v2.0.13) (2023-02-24)
diff --git a/libs/generated/nestjs-graphql/package.json b/libs/generated/nestjs-graphql/package.json
index 7c26008f3..3ed552c21 100644
--- a/libs/generated/nestjs-graphql/package.json
+++ b/libs/generated/nestjs-graphql/package.json
@@ -1,4 +1,4 @@
{
"name": "@trxn/generated-nestjs-graphql",
- "version": "2.0.13"
+ "version": "2.1.0-next.1"
}
diff --git a/libs/generated/nestjs-models-common/CHANGELOG.md b/libs/generated/nestjs-models-common/CHANGELOG.md
index 85b23c759..6686a0d0b 100644
--- a/libs/generated/nestjs-models-common/CHANGELOG.md
+++ b/libs/generated/nestjs-models-common/CHANGELOG.md
@@ -2,6 +2,14 @@
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
+# [2.1.0-next.1](https://github.com/tractr/traxion/compare/v2.1.0-next.0...v2.1.0-next.1) (2023-02-27)
+
+
+
+# [2.1.0-next.0](https://github.com/tractr/traxion/compare/v2.0.13...v2.1.0-next.0) (2023-02-27)
+
+
+
## [2.0.13](https://github.com/tractr/traxion/compare/v2.0.12...v2.0.13) (2023-02-24)
diff --git a/libs/generated/nestjs-models-common/package.json b/libs/generated/nestjs-models-common/package.json
index 90c18a0dd..8c4c0971d 100644
--- a/libs/generated/nestjs-models-common/package.json
+++ b/libs/generated/nestjs-models-common/package.json
@@ -1,6 +1,6 @@
{
"name": "@trxn/generated-nestjs-models-common",
- "version": "2.0.13",
+ "version": "2.1.0-next.1",
"exports": {
".": {
"import": "./src/index.js"
diff --git a/libs/generated/nestjs-models-rest/CHANGELOG.md b/libs/generated/nestjs-models-rest/CHANGELOG.md
index a2986eb8d..47f5c1a89 100644
--- a/libs/generated/nestjs-models-rest/CHANGELOG.md
+++ b/libs/generated/nestjs-models-rest/CHANGELOG.md
@@ -2,6 +2,14 @@
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
+# [2.1.0-next.1](https://github.com/tractr/traxion/compare/v2.1.0-next.0...v2.1.0-next.1) (2023-02-27)
+
+
+
+# [2.1.0-next.0](https://github.com/tractr/traxion/compare/v2.0.13...v2.1.0-next.0) (2023-02-27)
+
+
+
## [2.0.13](https://github.com/tractr/traxion/compare/v2.0.12...v2.0.13) (2023-02-24)
diff --git a/libs/generated/nestjs-models-rest/package.json b/libs/generated/nestjs-models-rest/package.json
index d4e4dcaca..d443f3369 100644
--- a/libs/generated/nestjs-models-rest/package.json
+++ b/libs/generated/nestjs-models-rest/package.json
@@ -1,6 +1,6 @@
{
"name": "@trxn/generated-nestjs-models-rest",
- "version": "2.0.13",
+ "version": "2.1.0-next.1",
"exports": {
".": {
"import": "./src/index.js"
diff --git a/libs/generated/nestjs-models/CHANGELOG.md b/libs/generated/nestjs-models/CHANGELOG.md
index f13664c50..e9b799a11 100644
--- a/libs/generated/nestjs-models/CHANGELOG.md
+++ b/libs/generated/nestjs-models/CHANGELOG.md
@@ -2,6 +2,14 @@
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
+# [2.1.0-next.1](https://github.com/tractr/traxion/compare/v2.1.0-next.0...v2.1.0-next.1) (2023-02-27)
+
+
+
+# [2.1.0-next.0](https://github.com/tractr/traxion/compare/v2.0.13...v2.1.0-next.0) (2023-02-27)
+
+
+
## [2.0.13](https://github.com/tractr/traxion/compare/v2.0.12...v2.0.13) (2023-02-24)
diff --git a/libs/generated/nestjs-models/package.json b/libs/generated/nestjs-models/package.json
index 88f4ebd3e..2d3a18e46 100644
--- a/libs/generated/nestjs-models/package.json
+++ b/libs/generated/nestjs-models/package.json
@@ -1,6 +1,6 @@
{
"name": "@trxn/generated-nestjs-models",
- "version": "2.0.13",
+ "version": "2.1.0-next.1",
"exports": {
".": "./dist/index.js",
"./mock": "./dist/mock.js"
diff --git a/libs/generated/prisma/CHANGELOG.md b/libs/generated/prisma/CHANGELOG.md
index 97fb09bf4..a1a6f9daa 100644
--- a/libs/generated/prisma/CHANGELOG.md
+++ b/libs/generated/prisma/CHANGELOG.md
@@ -2,6 +2,14 @@
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
+# [2.1.0-next.1](https://github.com/tractr/traxion/compare/v2.1.0-next.0...v2.1.0-next.1) (2023-02-27)
+
+
+
+# [2.1.0-next.0](https://github.com/tractr/traxion/compare/v2.0.13...v2.1.0-next.0) (2023-02-27)
+
+
+
## [2.0.13](https://github.com/tractr/traxion/compare/v2.0.12...v2.0.13) (2023-02-24)
diff --git a/libs/generated/prisma/package.json b/libs/generated/prisma/package.json
index 9edc7578d..22ea58e27 100644
--- a/libs/generated/prisma/package.json
+++ b/libs/generated/prisma/package.json
@@ -1,4 +1,4 @@
{
"name": "@trxn/generated-prisma",
- "version": "2.0.13"
+ "version": "2.1.0-next.1"
}
diff --git a/libs/generated/react-admin/CHANGELOG.md b/libs/generated/react-admin/CHANGELOG.md
index 707fc7b9c..bceb1e95e 100644
--- a/libs/generated/react-admin/CHANGELOG.md
+++ b/libs/generated/react-admin/CHANGELOG.md
@@ -2,6 +2,14 @@
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
+# [2.1.0-next.1](https://github.com/tractr/traxion/compare/v2.1.0-next.0...v2.1.0-next.1) (2023-02-27)
+
+
+
+# [2.1.0-next.0](https://github.com/tractr/traxion/compare/v2.0.13...v2.1.0-next.0) (2023-02-27)
+
+
+
## [2.0.13](https://github.com/tractr/traxion/compare/v2.0.12...v2.0.13) (2023-02-24)
diff --git a/libs/generated/react-admin/package.json b/libs/generated/react-admin/package.json
index eae514029..21335dfad 100644
--- a/libs/generated/react-admin/package.json
+++ b/libs/generated/react-admin/package.json
@@ -1,4 +1,4 @@
{
"name": "@trxn/generated-react-admin",
- "version": "2.0.13"
+ "version": "2.1.0-next.1"
}
diff --git a/libs/generated/rest-dtos/CHANGELOG.md b/libs/generated/rest-dtos/CHANGELOG.md
index 957dc0ebe..0a6907253 100644
--- a/libs/generated/rest-dtos/CHANGELOG.md
+++ b/libs/generated/rest-dtos/CHANGELOG.md
@@ -2,6 +2,14 @@
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
+# [2.1.0-next.1](https://github.com/tractr/traxion/compare/v2.1.0-next.0...v2.1.0-next.1) (2023-02-27)
+
+
+
+# [2.1.0-next.0](https://github.com/tractr/traxion/compare/v2.0.13...v2.1.0-next.0) (2023-02-27)
+
+
+
## [2.0.13](https://github.com/tractr/traxion/compare/v2.0.12...v2.0.13) (2023-02-24)
diff --git a/libs/generated/rest-dtos/package.json b/libs/generated/rest-dtos/package.json
index 81de24829..e8dbc16f3 100644
--- a/libs/generated/rest-dtos/package.json
+++ b/libs/generated/rest-dtos/package.json
@@ -1,6 +1,6 @@
{
"name": "@trxn/generated-rest-dtos",
- "version": "2.0.13",
+ "version": "2.1.0-next.1",
"dependencies": {
"tslib": "^2.3.1"
},
diff --git a/libs/generated/rext-client/CHANGELOG.md b/libs/generated/rext-client/CHANGELOG.md
index 957dc0ebe..0a6907253 100644
--- a/libs/generated/rext-client/CHANGELOG.md
+++ b/libs/generated/rext-client/CHANGELOG.md
@@ -2,6 +2,14 @@
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
+# [2.1.0-next.1](https://github.com/tractr/traxion/compare/v2.1.0-next.0...v2.1.0-next.1) (2023-02-27)
+
+
+
+# [2.1.0-next.0](https://github.com/tractr/traxion/compare/v2.0.13...v2.1.0-next.0) (2023-02-27)
+
+
+
## [2.0.13](https://github.com/tractr/traxion/compare/v2.0.12...v2.0.13) (2023-02-24)
diff --git a/libs/generated/rext-client/package.json b/libs/generated/rext-client/package.json
index a4c016c9c..2cdff52b8 100644
--- a/libs/generated/rext-client/package.json
+++ b/libs/generated/rext-client/package.json
@@ -1,6 +1,6 @@
{
"name": "@trxn/generated-rext-client",
- "version": "2.0.13",
+ "version": "2.1.0-next.1",
"dependencies": {
"tslib": "^2.3.1"
},
diff --git a/libs/hapify/generate-config/CHANGELOG.md b/libs/hapify/generate-config/CHANGELOG.md
index 48c11a0e4..e14effba2 100644
--- a/libs/hapify/generate-config/CHANGELOG.md
+++ b/libs/hapify/generate-config/CHANGELOG.md
@@ -2,6 +2,14 @@
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
+# [2.1.0-next.1](https://github.com/tractr/traxion/compare/v2.1.0-next.0...v2.1.0-next.1) (2023-02-27)
+
+
+
+# [2.1.0-next.0](https://github.com/tractr/traxion/compare/v2.0.13...v2.1.0-next.0) (2023-02-27)
+
+
+
## [2.0.13](https://github.com/tractr/traxion/compare/v2.0.12...v2.0.13) (2023-02-24)
diff --git a/libs/hapify/generate-config/package.json b/libs/hapify/generate-config/package.json
index b98ca8cee..69cbda97a 100644
--- a/libs/hapify/generate-config/package.json
+++ b/libs/hapify/generate-config/package.json
@@ -1,6 +1,6 @@
{
"name": "@trxn/hapify-generate-config",
- "version": "2.0.13",
+ "version": "2.1.0-next.1",
"description": "Generate hapify config",
"repository": {
"type": "git",
diff --git a/libs/hapify/hapify-common/CHANGELOG.md b/libs/hapify/hapify-common/CHANGELOG.md
index fdb98851d..d1d9ac9d0 100644
--- a/libs/hapify/hapify-common/CHANGELOG.md
+++ b/libs/hapify/hapify-common/CHANGELOG.md
@@ -2,6 +2,14 @@
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
+# [2.1.0-next.1](https://github.com/tractr/traxion/compare/v2.1.0-next.0...v2.1.0-next.1) (2023-02-27)
+
+
+
+# [2.1.0-next.0](https://github.com/tractr/traxion/compare/v2.0.13...v2.1.0-next.0) (2023-02-27)
+
+
+
## [2.0.13](https://github.com/tractr/traxion/compare/v2.0.12...v2.0.13) (2023-02-24)
diff --git a/libs/hapify/hapify-common/package.json b/libs/hapify/hapify-common/package.json
index 3c7dcadf5..a53ca40a7 100644
--- a/libs/hapify/hapify-common/package.json
+++ b/libs/hapify/hapify-common/package.json
@@ -1,6 +1,6 @@
{
"name": "@trxn/hapify-common",
- "version": "2.0.13",
+ "version": "2.1.0-next.1",
"description": "Hapify common helpers",
"repository": {
"type": "git",
diff --git a/libs/hapify/templates/angular-rext-client/CHANGELOG.md b/libs/hapify/templates/angular-rext-client/CHANGELOG.md
index a785a7b16..5c1c9c365 100644
--- a/libs/hapify/templates/angular-rext-client/CHANGELOG.md
+++ b/libs/hapify/templates/angular-rext-client/CHANGELOG.md
@@ -2,6 +2,14 @@
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
+# [2.1.0-next.1](https://github.com/tractr/traxion/compare/v2.1.0-next.0...v2.1.0-next.1) (2023-02-27)
+
+
+
+# [2.1.0-next.0](https://github.com/tractr/traxion/compare/v2.0.13...v2.1.0-next.0) (2023-02-27)
+
+
+
## [2.0.13](https://github.com/tractr/traxion/compare/v2.0.12...v2.0.13) (2023-02-24)
diff --git a/libs/hapify/templates/angular-rext-client/package.json b/libs/hapify/templates/angular-rext-client/package.json
index 32c8e1dc9..c2245e412 100644
--- a/libs/hapify/templates/angular-rext-client/package.json
+++ b/libs/hapify/templates/angular-rext-client/package.json
@@ -1,6 +1,6 @@
{
"name": "@trxn/hapify-templates-angular-rext-client",
- "version": "2.0.13",
+ "version": "2.1.0-next.1",
"description": "Template to generate an angular rest client with hapify",
"repository": {
"type": "git",
diff --git a/libs/hapify/templates/casl/CHANGELOG.md b/libs/hapify/templates/casl/CHANGELOG.md
index f6c0b9c52..b5870937e 100644
--- a/libs/hapify/templates/casl/CHANGELOG.md
+++ b/libs/hapify/templates/casl/CHANGELOG.md
@@ -2,6 +2,40 @@
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
+# [2.1.0-next.1](https://github.com/tractr/traxion/compare/v2.1.0-next.0...v2.1.0-next.1) (2023-02-27)
+
+
+
+# [2.1.0-next.0](https://github.com/tractr/traxion/compare/v2.0.13...v2.1.0-next.0) (2023-02-27)
+
+
+
+## [2.0.11-next.3](https://github.com/tractr/traxion/compare/v2.0.11-next.2...v2.0.11-next.3) (2023-02-22)
+
+
+
+## [2.0.11-next.2](https://github.com/tractr/traxion/compare/v2.0.11-next.1...v2.0.11-next.2) (2023-02-22)
+
+
+### Bug Fixes
+
+* add casl public permissions and MAILER_CLIENT token ([46f4b06](https://github.com/tractr/traxion/commit/46f4b06da9d46a79c36bde365cd817b46031e24f))
+
+
+
+## [2.0.11-next.1](https://github.com/tractr/traxion/compare/v2.0.11-next.0...v2.0.11-next.1) (2023-02-22)
+
+
+
+## [2.0.11-next.0](https://github.com/tractr/traxion/compare/v2.0.10...v2.0.11-next.0) (2023-02-22)
+
+
+### Features
+
+* clean authentication modules ([99b7db6](https://github.com/tractr/traxion/commit/99b7db69cc4f885ac885d147043003448895d66d))
+
+
+
## [2.0.13](https://github.com/tractr/traxion/compare/v2.0.12...v2.0.13) (2023-02-24)
diff --git a/libs/hapify/templates/casl/hapify/generated/casl/src/config/get-prisma-user-query.ts.hpf b/libs/hapify/templates/casl/hapify/generated/casl/src/config/get-prisma-user-query.ts.hpf
index b517e1ec1..4bfaacf2b 100644
--- a/libs/hapify/templates/casl/hapify/generated/casl/src/config/get-prisma-user-query.ts.hpf
+++ b/libs/hapify/templates/casl/hapify/generated/casl/src/config/get-prisma-user-query.ts.hpf
@@ -1,30 +1,39 @@
-import { Prisma <<=getModelListToImport()>>} from '@prisma/client';
+import { Prisma } from '@prisma/client';
+/**
+ * User select to retrieve all information for the user ownerships
+*/
+export const UserSelectOwnershipIds = Prisma.validator()({
+ select: <<=getSelectPrismaUserQueryFromHapify()>>,
+});
+
/**
* User export type that the userService.findUnique method will return
* by the getSelectPrismaUserQuery function
*/
-export type UserWithIds = <<=getUserFindUniqueReturnTypeFromHapify()>>;
-
+export type UserWithOwnershipIds = Prisma.UserGetPayload<
+ typeof UserSelectOwnershipIds
+>;
/**
* Get the select configuration for the prisma user query to be able
* to construct the user with the correct ids
*/
export function getSelectPrismaUserQuery(): Prisma.UserSelect {
- return <<=getSelectPrismaUserQueryFromHapify()>>;
+ return UserSelectOwnershipIds.select;
}
+
<<<
function getSelectPrismaUserQueryFromHapify() {
- const info = getOwnershipInformationsFromHapify();
+ const info = getOwnershipInformationFromHapify();
return JSON.stringify(info.select, null, 2);
}
function getUserFindUniqueReturnTypeFromHapify() {
- const info = getOwnershipInformationsFromHapify();
+ const info = getOwnershipInformationFromHapify();
return JSON.stringify(info.types, null, 2)
.replaceAll('"', '')
@@ -35,13 +44,13 @@ export function getSelectPrismaUserQuery(): Prisma.UserSelect {
}
function getModelListToImport() {
- const info = getOwnershipInformationsFromHapify();
+ const info = getOwnershipInformationFromHapify();
return info.modelListToImport.length === 0
? ''
: `, ${info.modelListToImport.join(', ')} `;
}
- function getOwnershipInformationsFromHapify() {
+ function getOwnershipInformationFromHapify() {
const models = root;
if (!models) return JSON.stringify({}, null, 2);
diff --git a/libs/hapify/templates/casl/hapify/generated/casl/src/config/role-permission.config.ts.hpf b/libs/hapify/templates/casl/hapify/generated/casl/src/config/role-permission.config.ts.hpf
index 145097006..9d132e576 100644
--- a/libs/hapify/templates/casl/hapify/generated/casl/src/config/role-permission.config.ts.hpf
+++ b/libs/hapify/templates/casl/hapify/generated/casl/src/config/role-permission.config.ts.hpf
@@ -1,18 +1,22 @@
+import { AbilityBuilder } from '@casl/ability';
import { UserRoles } from '@prisma/client';
import { getConcatValueByPath } from '@trxn/common';
-import { DefinePermissions } from '@trxn/nestjs-casl';
+import { DefinePermissions, DefinePublicPermissions, RolePermissions } from '@trxn/nestjs-casl';
import { AppAbility } from '../interfaces';
+import { UserWithOwnershipIds } from './get-prisma-user-query';
-export const guestRolePermissions: DefinePermissions = ({ can }) => {
+export const publicRolePermissions: DefinePublicPermissions> = ({ can }) => {
<>
<>
can('<<=access.action>>', '<>');
<>
<>
};
+
+export const guestRolePermissions: DefinePermissions, UserWithOwnershipIds> = publicRolePermissions;
-export const userRolePermissions: DefinePermissions = ({ can }, user) => {
+export const userRolePermissions: DefinePermissions, UserWithOwnershipIds> = ({ can }, user) => {
<>
// Configure permissions for <> from hapify models
<>
@@ -31,13 +35,14 @@ export const userRolePermissions: DefinePermissions = ({ can }, user
<>
};
-export const adminRolePermissions: DefinePermissions = ({ can }) => {
+export const adminRolePermissions: DefinePermissions, UserWithOwnershipIds> = ({ can }) => {
can('manage', 'all');
};
-export const rolePermissions: Record<
+export const rolePermissions: RolePermissions<
UserRoles,
- DefinePermissions
+ AbilityBuilder,
+ UserWithOwnershipIds
> = {
guest: guestRolePermissions,
user: userRolePermissions,
diff --git a/libs/hapify/templates/casl/package.json b/libs/hapify/templates/casl/package.json
index ded19a111..33bc92cea 100644
--- a/libs/hapify/templates/casl/package.json
+++ b/libs/hapify/templates/casl/package.json
@@ -1,6 +1,6 @@
{
"name": "@trxn/hapify-templates-casl",
- "version": "2.0.13",
+ "version": "2.1.0-next.1",
"description": "Hapify templates for casl class validators and types",
"repository": {
"type": "git",
diff --git a/libs/hapify/templates/dbml/CHANGELOG.md b/libs/hapify/templates/dbml/CHANGELOG.md
index 3999a1fe9..5c836a8bc 100644
--- a/libs/hapify/templates/dbml/CHANGELOG.md
+++ b/libs/hapify/templates/dbml/CHANGELOG.md
@@ -2,6 +2,14 @@
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
+# [2.1.0-next.1](https://github.com/tractr/traxion/compare/v2.1.0-next.0...v2.1.0-next.1) (2023-02-27)
+
+
+
+# [2.1.0-next.0](https://github.com/tractr/traxion/compare/v2.0.13...v2.1.0-next.0) (2023-02-27)
+
+
+
## [2.0.13](https://github.com/tractr/traxion/compare/v2.0.12...v2.0.13) (2023-02-24)
diff --git a/libs/hapify/templates/dbml/package.json b/libs/hapify/templates/dbml/package.json
index 1ccfc7ae6..77258098a 100644
--- a/libs/hapify/templates/dbml/package.json
+++ b/libs/hapify/templates/dbml/package.json
@@ -1,6 +1,6 @@
{
"name": "@trxn/hapify-templates-dbml",
- "version": "2.0.13",
+ "version": "2.1.0-next.1",
"description": "Generate DBML schema",
"repository": {
"type": "git",
diff --git a/libs/hapify/templates/models/CHANGELOG.md b/libs/hapify/templates/models/CHANGELOG.md
index 9fc12394a..56fcda84e 100644
--- a/libs/hapify/templates/models/CHANGELOG.md
+++ b/libs/hapify/templates/models/CHANGELOG.md
@@ -2,6 +2,14 @@
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
+# [2.1.0-next.1](https://github.com/tractr/traxion/compare/v2.1.0-next.0...v2.1.0-next.1) (2023-02-27)
+
+
+
+# [2.1.0-next.0](https://github.com/tractr/traxion/compare/v2.0.13...v2.1.0-next.0) (2023-02-27)
+
+
+
## [2.0.13](https://github.com/tractr/traxion/compare/v2.0.12...v2.0.13) (2023-02-24)
diff --git a/libs/hapify/templates/models/package.json b/libs/hapify/templates/models/package.json
index 6703a8d4e..d72868122 100644
--- a/libs/hapify/templates/models/package.json
+++ b/libs/hapify/templates/models/package.json
@@ -1,6 +1,6 @@
{
"name": "@trxn/hapify-templates-models",
- "version": "2.0.13",
+ "version": "2.1.0-next.1",
"description": "Hapify templates for models class validators and types",
"repository": {
"type": "git",
diff --git a/libs/hapify/templates/nestjs-graphql/CHANGELOG.md b/libs/hapify/templates/nestjs-graphql/CHANGELOG.md
index 20d0fe5eb..58ed12d07 100644
--- a/libs/hapify/templates/nestjs-graphql/CHANGELOG.md
+++ b/libs/hapify/templates/nestjs-graphql/CHANGELOG.md
@@ -2,6 +2,14 @@
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
+# [2.1.0-next.1](https://github.com/tractr/traxion/compare/v2.1.0-next.0...v2.1.0-next.1) (2023-02-27)
+
+
+
+# [2.1.0-next.0](https://github.com/tractr/traxion/compare/v2.0.13...v2.1.0-next.0) (2023-02-27)
+
+
+
## [2.0.13](https://github.com/tractr/traxion/compare/v2.0.12...v2.0.13) (2023-02-24)
diff --git a/libs/hapify/templates/nestjs-graphql/package.json b/libs/hapify/templates/nestjs-graphql/package.json
index 01962c2fa..fbb53d1b0 100644
--- a/libs/hapify/templates/nestjs-graphql/package.json
+++ b/libs/hapify/templates/nestjs-graphql/package.json
@@ -1,6 +1,6 @@
{
"name": "@trxn/hapify-templates-nestjs-graphql",
- "version": "2.0.13",
+ "version": "2.1.0-next.1",
"description": "Hapify templates for nestjs models",
"repository": {
"type": "git",
diff --git a/libs/hapify/templates/nestjs-models-common/CHANGELOG.md b/libs/hapify/templates/nestjs-models-common/CHANGELOG.md
index e4788eae7..c65f01ffd 100644
--- a/libs/hapify/templates/nestjs-models-common/CHANGELOG.md
+++ b/libs/hapify/templates/nestjs-models-common/CHANGELOG.md
@@ -2,6 +2,14 @@
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
+# [2.1.0-next.1](https://github.com/tractr/traxion/compare/v2.1.0-next.0...v2.1.0-next.1) (2023-02-27)
+
+
+
+# [2.1.0-next.0](https://github.com/tractr/traxion/compare/v2.0.13...v2.1.0-next.0) (2023-02-27)
+
+
+
## [2.0.13](https://github.com/tractr/traxion/compare/v2.0.12...v2.0.13) (2023-02-24)
diff --git a/libs/hapify/templates/nestjs-models-common/package.json b/libs/hapify/templates/nestjs-models-common/package.json
index 9ea5708b9..799b259c3 100644
--- a/libs/hapify/templates/nestjs-models-common/package.json
+++ b/libs/hapify/templates/nestjs-models-common/package.json
@@ -1,6 +1,6 @@
{
"name": "@trxn/hapify-templates-nestjs-models-common",
- "version": "2.0.13",
+ "version": "2.1.0-next.1",
"description": "Hapify templates for nestjs models common features",
"repository": {
"type": "git",
diff --git a/libs/hapify/templates/nestjs-models-rest/CHANGELOG.md b/libs/hapify/templates/nestjs-models-rest/CHANGELOG.md
index dfdcc97ed..c3aaa43bc 100644
--- a/libs/hapify/templates/nestjs-models-rest/CHANGELOG.md
+++ b/libs/hapify/templates/nestjs-models-rest/CHANGELOG.md
@@ -2,6 +2,14 @@
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
+# [2.1.0-next.1](https://github.com/tractr/traxion/compare/v2.1.0-next.0...v2.1.0-next.1) (2023-02-27)
+
+
+
+# [2.1.0-next.0](https://github.com/tractr/traxion/compare/v2.0.13...v2.1.0-next.0) (2023-02-27)
+
+
+
## [2.0.13](https://github.com/tractr/traxion/compare/v2.0.12...v2.0.13) (2023-02-24)
diff --git a/libs/hapify/templates/nestjs-models-rest/package.json b/libs/hapify/templates/nestjs-models-rest/package.json
index b9fe1c1c9..3f35b7462 100644
--- a/libs/hapify/templates/nestjs-models-rest/package.json
+++ b/libs/hapify/templates/nestjs-models-rest/package.json
@@ -1,6 +1,6 @@
{
"name": "@trxn/hapify-templates-nestjs-models-rest",
- "version": "2.0.13",
+ "version": "2.1.0-next.1",
"repository": {
"type": "git",
"url": "https://github.com/tractr/traxion"
diff --git a/libs/hapify/templates/nestjs-models/CHANGELOG.md b/libs/hapify/templates/nestjs-models/CHANGELOG.md
index f0a9a6009..cc86a8a8b 100644
--- a/libs/hapify/templates/nestjs-models/CHANGELOG.md
+++ b/libs/hapify/templates/nestjs-models/CHANGELOG.md
@@ -2,6 +2,14 @@
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
+# [2.1.0-next.1](https://github.com/tractr/traxion/compare/v2.1.0-next.0...v2.1.0-next.1) (2023-02-27)
+
+
+
+# [2.1.0-next.0](https://github.com/tractr/traxion/compare/v2.0.13...v2.1.0-next.0) (2023-02-27)
+
+
+
## [2.0.13](https://github.com/tractr/traxion/compare/v2.0.12...v2.0.13) (2023-02-24)
diff --git a/libs/hapify/templates/nestjs-models/package.json b/libs/hapify/templates/nestjs-models/package.json
index 07af90829..7a8cb962a 100644
--- a/libs/hapify/templates/nestjs-models/package.json
+++ b/libs/hapify/templates/nestjs-models/package.json
@@ -1,6 +1,6 @@
{
"name": "@trxn/hapify-templates-nestjs-models",
- "version": "2.0.13",
+ "version": "2.1.0-next.1",
"description": "Hapify templates for nestjs models",
"repository": {
"type": "git",
diff --git a/libs/hapify/templates/prisma/CHANGELOG.md b/libs/hapify/templates/prisma/CHANGELOG.md
index 7c20bce48..9126d9750 100644
--- a/libs/hapify/templates/prisma/CHANGELOG.md
+++ b/libs/hapify/templates/prisma/CHANGELOG.md
@@ -2,6 +2,14 @@
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
+# [2.1.0-next.1](https://github.com/tractr/traxion/compare/v2.1.0-next.0...v2.1.0-next.1) (2023-02-27)
+
+
+
+# [2.1.0-next.0](https://github.com/tractr/traxion/compare/v2.0.13...v2.1.0-next.0) (2023-02-27)
+
+
+
## [2.0.13](https://github.com/tractr/traxion/compare/v2.0.12...v2.0.13) (2023-02-24)
diff --git a/libs/hapify/templates/prisma/package.json b/libs/hapify/templates/prisma/package.json
index 6c3a469e8..a97205f26 100644
--- a/libs/hapify/templates/prisma/package.json
+++ b/libs/hapify/templates/prisma/package.json
@@ -1,6 +1,6 @@
{
"name": "@trxn/hapify-templates-prisma",
- "version": "2.0.13",
+ "version": "2.1.0-next.1",
"description": "Generate prisma hapify config",
"repository": {
"type": "git",
diff --git a/libs/hapify/templates/react-admin/CHANGELOG.md b/libs/hapify/templates/react-admin/CHANGELOG.md
index 4c32325ae..a1da59a86 100644
--- a/libs/hapify/templates/react-admin/CHANGELOG.md
+++ b/libs/hapify/templates/react-admin/CHANGELOG.md
@@ -2,6 +2,14 @@
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
+# [2.1.0-next.1](https://github.com/tractr/traxion/compare/v2.1.0-next.0...v2.1.0-next.1) (2023-02-27)
+
+
+
+# [2.1.0-next.0](https://github.com/tractr/traxion/compare/v2.0.13...v2.1.0-next.0) (2023-02-27)
+
+
+
## [2.0.13](https://github.com/tractr/traxion/compare/v2.0.12...v2.0.13) (2023-02-24)
diff --git a/libs/hapify/templates/react-admin/package.json b/libs/hapify/templates/react-admin/package.json
index ad01a3e69..404eb3f9d 100644
--- a/libs/hapify/templates/react-admin/package.json
+++ b/libs/hapify/templates/react-admin/package.json
@@ -1,6 +1,6 @@
{
"name": "@trxn/hapify-templates-react-admin",
- "version": "2.0.13",
+ "version": "2.1.0-next.1",
"description": "Template to generate a react admin configuration",
"repository": {
"type": "git",
diff --git a/libs/hapify/templates/rest-dtos/CHANGELOG.md b/libs/hapify/templates/rest-dtos/CHANGELOG.md
index 1bc98e7d5..4af1dac24 100644
--- a/libs/hapify/templates/rest-dtos/CHANGELOG.md
+++ b/libs/hapify/templates/rest-dtos/CHANGELOG.md
@@ -2,6 +2,14 @@
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
+# [2.1.0-next.1](https://github.com/tractr/traxion/compare/v2.1.0-next.0...v2.1.0-next.1) (2023-02-27)
+
+
+
+# [2.1.0-next.0](https://github.com/tractr/traxion/compare/v2.0.13...v2.1.0-next.0) (2023-02-27)
+
+
+
## [2.0.13](https://github.com/tractr/traxion/compare/v2.0.12...v2.0.13) (2023-02-24)
diff --git a/libs/hapify/templates/rest-dtos/package.json b/libs/hapify/templates/rest-dtos/package.json
index 90109cbe8..67c31b78c 100644
--- a/libs/hapify/templates/rest-dtos/package.json
+++ b/libs/hapify/templates/rest-dtos/package.json
@@ -1,6 +1,6 @@
{
"name": "@trxn/hapify-templates-rest-dtos",
- "version": "2.0.13",
+ "version": "2.1.0-next.1",
"description": "Hapify templates for models rest dtos",
"repository": {
"type": "git",
diff --git a/libs/hapify/templates/rext-client/CHANGELOG.md b/libs/hapify/templates/rext-client/CHANGELOG.md
index 0ba13ac8d..b1b1dcc74 100644
--- a/libs/hapify/templates/rext-client/CHANGELOG.md
+++ b/libs/hapify/templates/rext-client/CHANGELOG.md
@@ -2,6 +2,14 @@
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
+# [2.1.0-next.1](https://github.com/tractr/traxion/compare/v2.1.0-next.0...v2.1.0-next.1) (2023-02-27)
+
+
+
+# [2.1.0-next.0](https://github.com/tractr/traxion/compare/v2.0.13...v2.1.0-next.0) (2023-02-27)
+
+
+
## [2.0.13](https://github.com/tractr/traxion/compare/v2.0.12...v2.0.13) (2023-02-24)
diff --git a/libs/hapify/templates/rext-client/package.json b/libs/hapify/templates/rext-client/package.json
index 3c7c4d85e..a5b0e7018 100644
--- a/libs/hapify/templates/rext-client/package.json
+++ b/libs/hapify/templates/rext-client/package.json
@@ -1,6 +1,6 @@
{
"name": "@trxn/hapify-templates-rext-client",
- "version": "2.0.13",
+ "version": "2.1.0-next.1",
"description": "Template to generate a rest client with hapify",
"repository": {
"type": "git",
diff --git a/libs/hapify/update-templates-import-path/CHANGELOG.md b/libs/hapify/update-templates-import-path/CHANGELOG.md
index ed991de8b..8d85505f5 100644
--- a/libs/hapify/update-templates-import-path/CHANGELOG.md
+++ b/libs/hapify/update-templates-import-path/CHANGELOG.md
@@ -2,6 +2,14 @@
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
+# [2.1.0-next.1](https://github.com/tractr/traxion/compare/v2.1.0-next.0...v2.1.0-next.1) (2023-02-27)
+
+
+
+# [2.1.0-next.0](https://github.com/tractr/traxion/compare/v2.0.13...v2.1.0-next.0) (2023-02-27)
+
+
+
## [2.0.13](https://github.com/tractr/traxion/compare/v2.0.12...v2.0.13) (2023-02-24)
diff --git a/libs/hapify/update-templates-import-path/package.json b/libs/hapify/update-templates-import-path/package.json
index 219fa1af6..de77509c5 100644
--- a/libs/hapify/update-templates-import-path/package.json
+++ b/libs/hapify/update-templates-import-path/package.json
@@ -1,6 +1,6 @@
{
"name": "@trxn/hapify-update-templates-import-path",
- "version": "2.0.13",
+ "version": "2.1.0-next.1",
"description": "Update relative path in code generated by hapify",
"repository": {
"type": "git",
diff --git a/libs/nestjs/authentication/CHANGELOG.md b/libs/nestjs/authentication/CHANGELOG.md
index da3608d12..49cfe0ea1 100644
--- a/libs/nestjs/authentication/CHANGELOG.md
+++ b/libs/nestjs/authentication/CHANGELOG.md
@@ -2,6 +2,40 @@
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
+# [2.1.0-next.1](https://github.com/tractr/traxion/compare/v2.1.0-next.0...v2.1.0-next.1) (2023-02-27)
+
+
+
+# [2.1.0-next.0](https://github.com/tractr/traxion/compare/v2.0.13...v2.1.0-next.0) (2023-02-27)
+
+
+
+## [2.0.11-next.3](https://github.com/tractr/traxion/compare/v2.0.11-next.2...v2.0.11-next.3) (2023-02-22)
+
+
+
+## [2.0.11-next.2](https://github.com/tractr/traxion/compare/v2.0.11-next.1...v2.0.11-next.2) (2023-02-22)
+
+
+
+## [2.0.11-next.1](https://github.com/tractr/traxion/compare/v2.0.11-next.0...v2.0.11-next.1) (2023-02-22)
+
+
+
+## [2.0.11-next.0](https://github.com/tractr/traxion/compare/v2.0.10...v2.0.11-next.0) (2023-02-22)
+
+
+### Bug Fixes
+
+* resolve conversation and make the api start without settings env ([87d4465](https://github.com/tractr/traxion/commit/87d446509dd3c182c92a9d269dfbe24a826899ec))
+
+
+### Features
+
+* clean authentication modules ([99b7db6](https://github.com/tractr/traxion/commit/99b7db69cc4f885ac885d147043003448895d66d))
+
+
+
## [2.0.13](https://github.com/tractr/traxion/compare/v2.0.12...v2.0.13) (2023-02-24)
diff --git a/libs/nestjs/authentication/README.md b/libs/nestjs/authentication/README.md
index 4be41a140..979495b63 100644
--- a/libs/nestjs/authentication/README.md
+++ b/libs/nestjs/authentication/README.md
@@ -1,42 +1,65 @@
-# nestjs-authentication
+# Authentication Module
+
+The nestjs-authentication module is that will handle your authentication. It will
+by give you access to some standard guard to use jwt and login based strategy
+authentication. Under the hood this module use jwt and passport to authenticate
+the connections.
## Installation
-To install this librairy you have to install it first via npm, yarn or pnpm and
-install the required peerdependency `@trxn/nestjs-database`
+You can install the nestjs-authentication module using npm:
```bash
-npm i --save @trxn/nestjs-authentication @trxn/nestjs-database`
-```
+npm install --save @trxn/nestjs-authentication
+````
-After that you need to register the module into your main application.
-You'll need a UserService class provider register in your app (you can user the
-USER_SERVICE token generate by `hapify-templates-nestjs-models-common`).
+## Getting Started
-> app.module.ts
+In your workspace create you own AuthenticationModule that will configure the AuthenticationModule.
```typescript
import { Module } from '@nestjs/common';
import { AuthenticationModule } from '@trxn/nestjs-authentication';
-import { DatabaseModule } from '@trxn/nestjs-database';
+import { UserModule } from './user.module';
@Module({
- imports: [DatabaseModule.register(), AuthenticationModule.register({
- userService: 'USER_SERVICE',
+ imports: [AuthenticationModule.register({
+ imports: [UserModule]
})],
- controllers: [],
- providers: [{ provide: 'USER_SERVICE', useClass: MyUserService }],
})
export class AppModule {}
```
-You can override some options inside the register function.
+The UserModule here is the UserModule provided by `@trxn/nestjs-user` and that expose
+a UserService. You can use your own UserService class by providing it directly in the options:
+
+```typescript
+import { Module } from '@nestjs/common';
+
+import { AuthenticationModule } from '@trxn/nestjs-authentication';
+import { UserModule } from './user.module';
+
+@Module({
+ imports: [AuthenticationModule.register({
+ UserService: MyUserServiceClass
+ })],
+})
+export class AppModule {}
+```
+
+The UserService property respect the nestjs Provider type.
## Configuration
-Futhermore you need to tell to nestjs to authenticate all your route. To do that
-you need to register the global auth guard from nestjs-authentication:
+After the first configuration your routes are not yet protected. Authentication Module
+give access to you to some guard class that you can use across your project. One of
+the best method to authenticate your application is to force the authentication to
+all the routes of your application and whitelist only the route that you need to be
+public. To do so AuthenticationModule give you access a guard and a decorator `@Public`
+to mark the route as public.
+
+Here an example to authenticate all your routes:
```typescript
import {
@@ -45,7 +68,11 @@ import {
} from '@trxn/nestjs-authentication';
@Module({
- imports: [DatabaseModule.register(), AuthenticationModule.register()],
+ imports: [
+ AuthenticationModule.register(
+ //... provide a UserService class
+ ),
+ ],
controllers: [],
providers: [
{
@@ -57,8 +84,39 @@ import {
export class AppModule {}
```
-In the future more global auth guard will be added to the authentication
-package.
+## CustomUserSelect
+
+The AuthenticationModule is responsible to hydrate you user when a request hit your api.
+Some time you don't want only the user but you want to join some data attached to it.
+This module let you configured a object that will be used in junction with the `UserService``
+provided to select the information to use to fetch the user.
+
+```ts
+@Module({
+ imports: [
+ AuthenticationModule.register(
+ //... the UserService configuration
+
+ customSelect: {
+ id: true,
+ roles: true,
+ profile: {
+ name: true,
+ address: true,
+ // ...
+ }
+ }
+ ),
+ ],
+ controllers: [],
+ providers: [
+ {
+ provide: APP_GUARD,
+ useClass: JwtGlobalAuthGuard,
+ },
+ ],
+})
+export cla
## Cookie authentication
@@ -66,7 +124,7 @@ You need if you want to use the authentication from cookie to add the cookie
parser package to your app module. You can look at the
[nestjs documentation](https://docs.nestjs.com/techniques/cookies#cookies).
**You must provide one or more secret to the cookie-parser package**,
-`nestjs-authentication use only signedCookie in production mode.
+`nestjs-authentication` use only signedCookie in production mode.
```typescript
import * as cookieParser from 'cookie-parser';
@@ -74,11 +132,33 @@ import * as cookieParser from 'cookie-parser';
app.use(cookieParser('myScret'));
```
-## Bcrypt online generator
+## Encryption
+
+By default AuthenticationModule use Bcrypt to parse and read the password.
+If you need to use something else you can provide to the AuthenticationModule your own
+`EncryptionService` that need to implement a `compare` and a `hash` method.
+
+```ts
+@Module({
+ imports: [
+ AuthenticationModule.register(
+ //... provide a UserService class
+ EncryptionService: EncryptionService
+ ),
+ ],
+ controllers: [],
+ providers: [
+ {
+ provide: APP_GUARD,
+ useClass: JwtGlobalAuthGuard,
+ },
+ ],
+})
+export class AppModule {}
+```
-To be able to test you can use these [bcrypt online generator](https://www.browserling.com/tools/bcrypt) to crypt your password.
+You can look at the BcryptModule to found some example.
-## Running unit tests
+## Bcrypt online generator
-Run `nx test nestjs-authentication` to execute the unit tests via
-[Jest](https://jestjs.io).
+To be able to test you can use these [bcrypt online generator](https://www.browserling.com/tools/bcrypt) to crypt your passwords.
diff --git a/libs/nestjs/authentication/package.json b/libs/nestjs/authentication/package.json
index 621706557..fa7da00a7 100644
--- a/libs/nestjs/authentication/package.json
+++ b/libs/nestjs/authentication/package.json
@@ -1,6 +1,6 @@
{
"name": "@trxn/nestjs-authentication",
- "version": "2.0.13",
+ "version": "2.1.0-next.1",
"repository": {
"type": "git",
"url": "https://github.com/tractr/traxion"
diff --git a/libs/nestjs/authentication/src/authentication.module-definition.ts b/libs/nestjs/authentication/src/authentication.module-definition.ts
index 661fd66fe..e65964871 100644
--- a/libs/nestjs/authentication/src/authentication.module-definition.ts
+++ b/libs/nestjs/authentication/src/authentication.module-definition.ts
@@ -1,10 +1,49 @@
import { ConfigurableModuleBuilder } from '@nestjs/common';
+import { ENCRYPTION_SERVICE } from './constants';
import { AuthenticationModuleOptions } from './interfaces';
+import { EncryptionService } from '@trxn/nestjs-bcrypt';
+import {
+ addImportsAndProvidersExtra,
+ addProviderWithInjectionTokenExtra,
+ ImportsExtra,
+ ProvidersExtra,
+ ProviderWithInjectionToken,
+} from '@trxn/nestjs-core';
+import { USER_SERVICE, UserService } from '@trxn/nestjs-user';
+
export const {
ConfigurableModuleClass,
MODULE_OPTIONS_TOKEN,
ASYNC_OPTIONS_TYPE,
OPTIONS_TYPE,
-} = new ConfigurableModuleBuilder().build();
+} = new ConfigurableModuleBuilder()
+ .setExtras<
+ ImportsExtra &
+ ProvidersExtra & {
+ UserService?: ProviderWithInjectionToken<
+ typeof USER_SERVICE,
+ UserService
+ >;
+ EncryptionService?: ProviderWithInjectionToken<
+ typeof ENCRYPTION_SERVICE,
+ EncryptionService
+ >;
+ }
+ >(
+ { imports: [], providers: [] },
+ addImportsAndProvidersExtra(
+ (definition, { UserService: User, EncryptionService: Encryption }) =>
+ addProviderWithInjectionTokenExtra(
+ addProviderWithInjectionTokenExtra(
+ definition,
+ ENCRYPTION_SERVICE,
+ Encryption,
+ ),
+ USER_SERVICE,
+ User,
+ ),
+ ),
+ )
+ .build();
diff --git a/libs/nestjs/authentication/src/authentication.module.spec.ts b/libs/nestjs/authentication/src/authentication.module.spec.ts
index 22c8b2f68..af39e86a4 100644
--- a/libs/nestjs/authentication/src/authentication.module.spec.ts
+++ b/libs/nestjs/authentication/src/authentication.module.spec.ts
@@ -1,27 +1,28 @@
-import { INestApplication } from '@nestjs/common';
+import { INestApplication, Type } from '@nestjs/common';
import { APP_GUARD } from '@nestjs/core';
import { Test, TestingModule } from '@nestjs/testing';
-import { Prisma } from '@prisma/client';
import { mockDeep, MockProxy } from 'jest-mock-extended';
import * as jwt from 'jsonwebtoken';
import * as request from 'supertest';
-import { AuthenticationEndpointMockController } from '../mocks';
import { AuthenticationModule } from './authentication.module';
import { JwtGlobalAuthGuard } from './guards';
import { AuthenticationService } from './services';
import { JwtStrategy, LocalStrategy } from './strategies';
+import { AuthenticationEndpointMockController } from '../mocks';
+
+import { UserService } from '@trxn/nestjs-user';
describe('Authentication Module', () => {
let app: INestApplication;
- let mockUserService: MockProxy>;
+ let mockUserService: MockProxy>;
it('should load the module when using register', async () => {
- mockUserService = mockDeep>();
+ mockUserService = mockDeep>();
const moduleFixture: TestingModule = await Test.createTestingModule({
imports: [
AuthenticationModule.register({
- userService: mockUserService,
+ providers: [{ provide: UserService, useValue: mockUserService }],
jwtModuleOptions: {
secret: 'integration-tests',
},
@@ -42,14 +43,16 @@ describe('Authentication Module', () => {
});
it('should load the module when using registerAsync', async () => {
- mockUserService = mockDeep>();
+ mockUserService = mockDeep>();
const moduleFixture: TestingModule = await Test.createTestingModule({
imports: [
- AuthenticationModule.register({
- userService: mockUserService,
- jwtModuleOptions: {
- secret: 'integration-tests',
- },
+ AuthenticationModule.registerAsync({
+ providers: [{ provide: UserService, useValue: mockUserService }],
+ useFactory: () => ({
+ jwtModuleOptions: {
+ secret: 'integration-tests',
+ },
+ }),
}),
],
providers: [],
@@ -68,13 +71,13 @@ describe('Authentication Module', () => {
describe('Authentication module when using jwt global guard', () => {
beforeEach(async () => {
- mockUserService = mockDeep>();
+ mockUserService = mockDeep>();
const moduleFixture: TestingModule = await Test.createTestingModule({
controllers: [AuthenticationEndpointMockController],
imports: [
AuthenticationModule.register({
- userService: mockUserService,
+ providers: [{ provide: UserService, useValue: mockUserService }],
jwtModuleOptions: {
secret: 'integration-tests',
},
@@ -119,12 +122,12 @@ describe('Authentication Module', () => {
describe('Authentication Module without global guards', () => {
beforeEach(async () => {
- mockUserService = mockDeep>();
+ mockUserService = mockDeep>();
const moduleFixture: TestingModule = await Test.createTestingModule({
controllers: [AuthenticationEndpointMockController],
imports: [
AuthenticationModule.register({
- userService: mockUserService,
+ providers: [{ provide: UserService, useValue: mockUserService }],
jwtModuleOptions: {
secret: 'integration-tests',
},
diff --git a/libs/nestjs/authentication/src/authentication.module.ts b/libs/nestjs/authentication/src/authentication.module.ts
index 8c2c8ce45..ead2988cb 100644
--- a/libs/nestjs/authentication/src/authentication.module.ts
+++ b/libs/nestjs/authentication/src/authentication.module.ts
@@ -17,7 +17,6 @@ import {
CookieOptionsService,
HashService,
StrategyOptionsService,
- UserAuthenticationService,
} from './services';
import { JwtOptionsService } from './services/jwt-options.service';
import { JwtStrategy, LocalStrategy } from './strategies';
@@ -28,7 +27,7 @@ import { LoggerModule } from '@trxn/nestjs-core';
@Module({})
export class AuthenticationModule extends ConfigurableModuleClass {
private static createModule(module: DynamicModule): DynamicModule {
- // When https://github.com/nestjs/jwt/pull/1065 is merged, this can be simplified to:
+ // FIXME: When https://github.com/nestjs/jwt/pull/1065 is merged, this can be simplified to:
// Should remove this moduleOptions variables
const moduleOptions = {
...module,
@@ -44,6 +43,10 @@ export class AuthenticationModule extends ConfigurableModuleClass {
BcryptModule.register({}),
LoggerModule,
JwtModule.registerAsync({
+ // FIXME: When https://github.com/nestjs/jwt/pull/1065 is merged, this can be simplified to:
+ // useFactory: (passwordModuleOptions: PasswordModuleOptions) =>
+ // passwordModuleOptions?.jwtModuleOptions || {},
+ // provideInjectionTokensFrom: module.providers,
imports: [moduleOptions],
useFactory: (jwtOptionsService: JwtOptionsService) =>
jwtOptionsService.jwtModuleOptions,
@@ -74,7 +77,6 @@ export class AuthenticationModule extends ConfigurableModuleClass {
LocalStrategy,
JwtStrategy,
HashService,
- UserAuthenticationService,
{
provide: APP_FILTER,
useClass: UnauthorizedExceptionFilter,
diff --git a/libs/nestjs/authentication/src/constants/authentication.constants.ts b/libs/nestjs/authentication/src/constants/authentication.constants.ts
index 08e58fe0e..56b31f677 100644
--- a/libs/nestjs/authentication/src/constants/authentication.constants.ts
+++ b/libs/nestjs/authentication/src/constants/authentication.constants.ts
@@ -1,11 +1,11 @@
-export const AUTHENTICATION_DEFAULT_COOKIE_NAME = 'authCookie';
+export const DEFAULT_COOKIE_NAME = 'authCookie';
/**
* Default cookie TTL (24h)
*/
-export const AUTHENTICATION_DEFAULT_COOKIE_TTL = 1000 * 60 * 60 * 24;
-export const AUTHENTICATION_DEFAULT_AUTH_TOKEN = 'authToken';
-export const AUTHENTICATION_DEFAULT_QUERY_PARAM_NAME = 'authToken';
+export const DEFAULT_COOKIE_TTL = 1000 * 60 * 60 * 24;
+export const DEFAULT_AUTH_TOKEN = 'authToken';
+export const DEFAULT_URL_QUERY_PARAM_NAME = 'authToken';
export const DEFAULT_ID_FIELD = 'id';
export const DEFAULT_LOGIN_FIELD = 'email';
diff --git a/libs/nestjs/authentication/src/constants/encryption.constants.ts b/libs/nestjs/authentication/src/constants/encryption.constants.ts
new file mode 100644
index 000000000..41fc48c11
--- /dev/null
+++ b/libs/nestjs/authentication/src/constants/encryption.constants.ts
@@ -0,0 +1 @@
+export const ENCRYPTION_SERVICE = 'ENCRYPTION_SERVICE' as const;
diff --git a/libs/nestjs/authentication/src/constants/index.ts b/libs/nestjs/authentication/src/constants/index.ts
index 552a1b73a..cca2bec57 100644
--- a/libs/nestjs/authentication/src/constants/index.ts
+++ b/libs/nestjs/authentication/src/constants/index.ts
@@ -1 +1,3 @@
export * from './authentication.constants';
+export * from './encryption.constants';
+export * from './local-strategy.constants';
diff --git a/libs/nestjs/authentication/src/constants/local-strategy.constants.ts b/libs/nestjs/authentication/src/constants/local-strategy.constants.ts
new file mode 100644
index 000000000..c095293c7
--- /dev/null
+++ b/libs/nestjs/authentication/src/constants/local-strategy.constants.ts
@@ -0,0 +1,3 @@
+export const DEFAULT_LOCAL_USERNAME_FIELD = 'email';
+export const DEFAULT_LOCAL_PASSWORD_FIELD = 'password';
+export const DEFAULT_LOCAL_PASS_REQ_TO_CALLBACK = true;
diff --git a/libs/nestjs/authentication/src/controllers/login.controller.spec.ts b/libs/nestjs/authentication/src/controllers/login.controller.spec.ts
index 4e1438dbb..e1ab0490c 100644
--- a/libs/nestjs/authentication/src/controllers/login.controller.spec.ts
+++ b/libs/nestjs/authentication/src/controllers/login.controller.spec.ts
@@ -5,26 +5,27 @@ import { mockDeep, MockProxy } from 'jest-mock-extended';
import * as jwt from 'jsonwebtoken';
import * as request from 'supertest';
+import { LoginController } from './login.controller';
import { MODULE_OPTIONS_TOKEN } from '../authentication.module-definition';
import {
AuthenticationService,
CookieOptionsService,
StrategyOptionsService,
- UserAuthenticationService,
} from '../services';
import { JwtOptionsService } from '../services/jwt-options.service';
import { JwtStrategy, LocalStrategy } from '../strategies';
-import { LoginController } from './login.controller';
+
+import { UserService } from '@trxn/nestjs-user';
describe('Login Controller', () => {
let app: INestApplication;
- let mockUserAuthenticationService: MockProxy;
+ let mockUserService: MockProxy;
let mockAuthenticationService: MockProxy;
let mockUser: User;
beforeAll(async () => {
mockAuthenticationService = mockDeep();
- mockUserAuthenticationService = mockDeep();
+ mockUserService = mockDeep();
mockUser = {
id: '1',
@@ -36,8 +37,8 @@ describe('Login Controller', () => {
controllers: [LoginController],
providers: [
{
- provide: UserAuthenticationService,
- useValue: mockUserAuthenticationService,
+ provide: UserService,
+ useValue: mockUserService,
},
{
provide: AuthenticationService,
@@ -99,7 +100,7 @@ describe('Login Controller', () => {
describe('GET /me', () => {
it('/me get the user information back and use the jwt auth strategy', async () => {
const jwtToken = jwt.sign({ sub: '1' }, 'login-controller-secret');
- mockUserAuthenticationService.getUserFromId.mockResolvedValue(mockUser);
+ mockUserService.findUserById.mockResolvedValue(mockUser);
const response = await request(app.getHttpServer())
.get('/me')
@@ -108,9 +109,7 @@ describe('Login Controller', () => {
expect(response.body).toEqual(mockUser);
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(mockUserAuthenticationService.getUserFromId).toHaveBeenCalledWith(
- '1',
- );
+ expect(mockUserService.findUserById).toHaveBeenCalledTimes(2);
});
});
diff --git a/libs/nestjs/authentication/src/controllers/login.controller.ts b/libs/nestjs/authentication/src/controllers/login.controller.ts
index bb3d417ba..4e4b508d9 100644
--- a/libs/nestjs/authentication/src/controllers/login.controller.ts
+++ b/libs/nestjs/authentication/src/controllers/login.controller.ts
@@ -9,34 +9,30 @@ import {
UseGuards,
} from '@nestjs/common';
import { ApiBody } from '@nestjs/swagger';
-import { User } from '@prisma/client';
import { Request, Response } from 'express';
import { AccessTokenDto } from '../dtos';
import { LoginPostBodyDto } from '../dtos/login-form.dto';
import { JwtAuthGuard, LocalAuthGuard, PublicGuard } from '../guards';
-import {
- AuthenticationService,
- CookieOptionsService,
- UserAuthenticationService,
-} from '../services';
+import { AuthenticationService, CookieOptionsService } from '../services';
import { CurrentUser } from '@trxn/nestjs-core';
+import { MinimalUser, User, UserService } from '@trxn/nestjs-user';
@Controller()
export class LoginController {
constructor(
private readonly cookieOptionsService: CookieOptionsService,
- private readonly userAuthenticationService: UserAuthenticationService,
private readonly authenticationService: AuthenticationService,
+ private readonly userService: UserService,
) {}
@UseGuards(LocalAuthGuard)
@Post('login')
@ApiBody({ type: LoginPostBodyDto })
@HttpCode(200)
- async login(
- @Req() req: Request & { secret?: string; user: User },
+ async login(
+ @Req() req: Request & { secret?: string; user: U },
@Res({ passthrough: true }) res: Response,
): Promise {
const token = await this.authenticationService.login(req.user);
@@ -62,18 +58,17 @@ export class LoginController {
@Get('me')
@UseGuards(JwtAuthGuard)
- async me(
- @Req() req: Request & { user: User },
- @CurrentUser() currentUserInfo: User,
- ): Promise {
- const user = await this.userAuthenticationService.getUserFromId(
- currentUserInfo.id,
+ async me(
+ @CurrentUser() currentUser: U,
+ ): Promise {
+ const user = await this.userService.findUserById(
+ this.userService.getIdFromUser(currentUser),
);
if (!user) {
throw new BadRequestException();
}
- return user as User;
+ return user;
}
}
diff --git a/libs/nestjs/authentication/src/interfaces/authentication-module-options.interface.ts b/libs/nestjs/authentication/src/interfaces/authentication-module-options.interface.ts
index 5d775a9a6..e455ce80b 100644
--- a/libs/nestjs/authentication/src/interfaces/authentication-module-options.interface.ts
+++ b/libs/nestjs/authentication/src/interfaces/authentication-module-options.interface.ts
@@ -1,11 +1,10 @@
import { JwtModuleOptions } from '@nestjs/jwt';
import { IAuthModuleOptions as PassportModuleOptions } from '@nestjs/passport';
-import { Prisma, User } from '@prisma/client';
import { CookieOptions } from 'express';
import { StrategyOptions as JwtStrategyOptions } from 'passport-jwt';
import { IStrategyOptionsWithRequest as LocalStrategyOptions } from 'passport-local';
-import { EncryptionService } from '@trxn/nestjs-bcrypt';
+import { MinimalUser, User } from '@trxn/nestjs-user';
export type UserInfo = {
id: string | number;
@@ -17,35 +16,16 @@ export type UserInfo = {
* The public interface of the AuthenticationOptions.
*/
export interface AuthenticationModuleOptions {
- /**
- * Options to configure the user that will be manipulated by the authentication module.
- */
- user?: {
- fields?: {
- id?: string;
- email?: string;
- password?: string;
- login?: string;
- };
-
- customSelect?: Prisma.UserSelect;
- };
-
- /**
- * Options to configure the user service.
- */
- userService: Prisma.UserDelegate;
-
- /**
- * Options to hash the password to be stored in the database.
- */
- encryptionService?: EncryptionService;
+ customSelect?: Record;
/**
* Options to configure the information that will be stored inside the JWT
* token.
*/
- getUserJWT?: (user: User) => Record;
+ transformJwtPayload?: (
+ payload: Record,
+ user: U,
+ ) => Record;
/**
* Options to configure the jwt module (these options are used directly by the jwt module).
diff --git a/libs/nestjs/authentication/src/services/authentication.service.spec.ts b/libs/nestjs/authentication/src/services/authentication.service.spec.ts
index 8a4aa8e0e..802dc17a3 100644
--- a/libs/nestjs/authentication/src/services/authentication.service.spec.ts
+++ b/libs/nestjs/authentication/src/services/authentication.service.spec.ts
@@ -5,23 +5,24 @@ import { Test, TestingModule } from '@nestjs/testing';
import { User } from '@prisma/client';
import { mockDeep, MockProxy, mockReset } from 'jest-mock-extended';
-import { MODULE_OPTIONS_TOKEN } from '../authentication.module-definition';
-import { AuthenticationModuleOptions } from '../interfaces';
import { AuthenticationService } from './authentication.service';
import { HashService } from './hash.service';
-import { UserAuthenticationService } from './user-authentication.service';
+import { MODULE_OPTIONS_TOKEN } from '../authentication.module-definition';
+import { AuthenticationModuleOptions } from '../interfaces';
+
+import { UserService } from '@trxn/nestjs-user';
describe('AuthService', () => {
let authService: AuthenticationService;
let mockJwtService: MockProxy;
- let mockUserAuthenticationService: MockProxy;
+ let mockUserService: MockProxy;
let mockAuthenticationModuleOptions: MockProxy;
let mockHashService: MockProxy;
beforeEach(async () => {
mockJwtService = mockDeep();
- mockUserAuthenticationService = mockDeep();
+ mockUserService = mockDeep();
mockHashService = mockDeep();
mockAuthenticationModuleOptions =
mockDeep() as MockProxy;
@@ -34,8 +35,8 @@ describe('AuthService', () => {
useValue: mockAuthenticationModuleOptions,
},
{
- provide: UserAuthenticationService,
- useValue: mockUserAuthenticationService,
+ provide: UserService,
+ useValue: mockUserService,
},
{ provide: JwtService, useValue: mockJwtService },
{ provide: HashService, useValue: mockHashService },
@@ -47,7 +48,7 @@ describe('AuthService', () => {
afterEach(() => {
mockReset(mockJwtService);
- mockReset(mockUserAuthenticationService);
+ mockReset(mockUserService);
mockReset(mockHashService);
});
@@ -62,12 +63,8 @@ describe('AuthService', () => {
email: 'login',
password: 'password',
} as User;
- mockUserAuthenticationService.getUserFromLogin.mockResolvedValueOnce(
- user,
- );
- mockUserAuthenticationService.getPasswordFromUser.mockResolvedValueOnce(
- 'hash',
- );
+ mockUserService.findUserByLogin.mockResolvedValueOnce(user);
+ mockUserService.getUserPassword.mockResolvedValueOnce('hash');
mockHashService.compare.mockResolvedValueOnce(true);
@@ -82,39 +79,31 @@ describe('AuthService', () => {
email: 'login',
password: 'password',
} as User;
- mockUserAuthenticationService.getUserFromLogin.mockResolvedValueOnce(
- user,
- );
- mockUserAuthenticationService.getPasswordFromUser.mockResolvedValueOnce(
- 'hash',
- );
+ mockUserService.findUserByLogin.mockResolvedValueOnce(user);
+ mockUserService.getUserPassword.mockResolvedValueOnce('hash');
mockHashService.compare.mockResolvedValueOnce(false);
let result = await authService.validateUser('login', 'password');
expect(result).toBe(null);
- mockUserAuthenticationService.getUserFromLogin.mockResolvedValueOnce(
- user,
- );
- mockUserAuthenticationService.getPasswordFromUser.mockResolvedValueOnce(
- null,
- );
+ mockUserService.findUserByLogin.mockResolvedValueOnce(user);
+ mockUserService.getPasswordFromUser.mockReturnValueOnce(null);
result = await authService.validateUser('login', 'password');
expect(result).toBe(null);
- mockUserAuthenticationService.getUserFromLogin.mockResolvedValueOnce(
- null,
- );
+ mockUserService.findUserByLogin.mockResolvedValueOnce(null);
result = await authService.validateUser('login', 'password');
expect(result).toBe(null);
});
});
- describe('createUserJWT', () => {
- it('should create a User JWT with the getUserJWT from the config', async () => {
- const spyGetUserJWT = jest.fn().mockReturnValue({ id: 'test' });
- mockAuthenticationModuleOptions.getUserJWT = spyGetUserJWT;
+ describe('createAccessToken', () => {
+ it('should create a User JWT with the transformJwtPayload from the config', async () => {
+ const transformJwtPayload = jest
+ .fn()
+ .mockImplementation((payload) => ({ ...payload, id: 'test' }));
+ mockAuthenticationModuleOptions.transformJwtPayload = transformJwtPayload;
const user = {
id: '1',
@@ -122,7 +111,7 @@ describe('AuthService', () => {
password: 'password',
} as User;
mockJwtService.sign.mockReturnValue('jwt');
- const compare = await authService.createUserJWT(user);
+ const compare = await authService.createAccessToken(user);
expect(mockJwtService.sign).toHaveBeenCalledTimes(1);
expect(mockJwtService.sign).toHaveBeenCalledWith({
@@ -130,21 +119,21 @@ describe('AuthService', () => {
id: 'test',
});
- expect(spyGetUserJWT).toHaveBeenCalledTimes(1);
- expect(spyGetUserJWT).toHaveBeenCalledWith(user);
+ expect(transformJwtPayload).toHaveBeenCalledTimes(1);
+ expect(transformJwtPayload).toHaveBeenCalledWith({ sub: '1' }, user);
expect(compare).toEqual('jwt');
});
it('should create a User JWT', async () => {
- mockAuthenticationModuleOptions.getUserJWT = undefined;
+ mockAuthenticationModuleOptions.transformJwtPayload = undefined;
const user = {
id: '1',
email: 'login',
password: 'password',
} as User;
mockJwtService.sign.mockReturnValue('jwt');
- const compare = await authService.createUserJWT(user);
+ const compare = await authService.createAccessToken(user);
expect(mockJwtService.sign).toHaveBeenCalledTimes(1);
expect(mockJwtService.sign).toHaveBeenCalledWith({ sub: user.id });
@@ -160,11 +149,11 @@ describe('AuthService', () => {
email: 'login',
password: 'password',
} as User;
- const { createUserJWT } = authService;
+ const { createAccessToken } = authService;
const mockCreateUserJWT = jest.fn().mockReturnValue('jwt');
- authService.createUserJWT = mockCreateUserJWT;
+ authService.createAccessToken = mockCreateUserJWT;
const loggedIn = await authService.login(user);
- authService.createUserJWT = createUserJWT;
+ authService.createAccessToken = createAccessToken;
expect(mockCreateUserJWT).toHaveBeenCalledTimes(1);
expect(mockCreateUserJWT).toHaveBeenCalledWith(user);
diff --git a/libs/nestjs/authentication/src/services/authentication.service.ts b/libs/nestjs/authentication/src/services/authentication.service.ts
index 3e96a6cca..d8a70e420 100644
--- a/libs/nestjs/authentication/src/services/authentication.service.ts
+++ b/libs/nestjs/authentication/src/services/authentication.service.ts
@@ -1,29 +1,34 @@
import { Inject, Injectable } from '@nestjs/common';
import { JwtService } from '@nestjs/jwt';
-import { User } from '@prisma/client';
+import { HashService } from './hash.service';
import { MODULE_OPTIONS_TOKEN } from '../authentication.module-definition';
import { AccessTokenDto } from '../dtos';
import { AuthenticationModuleOptions } from '../interfaces';
-import { HashService } from './hash.service';
-import { UserAuthenticationService } from './user-authentication.service';
+
+import { MinimalUser, User, UserService } from '@trxn/nestjs-user';
@Injectable()
export class AuthenticationService {
constructor(
@Inject(MODULE_OPTIONS_TOKEN)
private readonly authenticationOptions: AuthenticationModuleOptions,
- private readonly userAuthenticationService: UserAuthenticationService,
+ private readonly userService: UserService,
private readonly jwtService: JwtService,
private readonly hashService: HashService,
) {}
- async validateUser(login: string, password: string): Promise {
- const user = await this.userAuthenticationService.getUserFromLogin(login);
+ async validateUser(
+ login: string,
+ password: string,
+ ): Promise {
+ const user = await this.userService.findUserByLogin(login);
if (!user) return null;
- const passwordHash =
- await this.userAuthenticationService.getPasswordFromUser(user);
+ const passwordHash = await this.userService.getUserPassword(
+ this.userService.getIdFromUser(user),
+ );
+
if (!passwordHash) return null;
const isValid = await this.hashService.compare(password, passwordHash);
@@ -32,18 +37,17 @@ export class AuthenticationService {
return user;
}
- async createUserJWT(user: User): Promise {
- return this.jwtService.sign({
- sub: user.id,
- ...(this.authenticationOptions.getUserJWT
- ? this.authenticationOptions.getUserJWT(user)
- : {}),
- });
+ async createAccessToken(
+ user: U,
+ ): Promise {
+ const { transformJwtPayload = (payload) => payload } =
+ this.authenticationOptions;
+ return this.jwtService.sign(transformJwtPayload({ sub: user.id }, user));
}
- async login(user: User): Promise {
+ async login(user: U): Promise {
return {
- accessToken: await this.createUserJWT(user),
+ accessToken: await this.createAccessToken(user),
};
}
}
diff --git a/libs/nestjs/authentication/src/services/cookie-options.service.ts b/libs/nestjs/authentication/src/services/cookie-options.service.ts
index 46d90a9fd..a51ea6e00 100644
--- a/libs/nestjs/authentication/src/services/cookie-options.service.ts
+++ b/libs/nestjs/authentication/src/services/cookie-options.service.ts
@@ -2,8 +2,8 @@ import { Inject, Injectable } from '@nestjs/common';
import { MODULE_OPTIONS_TOKEN } from '../authentication.module-definition';
import {
- AUTHENTICATION_DEFAULT_COOKIE_NAME,
- AUTHENTICATION_DEFAULT_QUERY_PARAM_NAME,
+ DEFAULT_COOKIE_NAME,
+ DEFAULT_URL_QUERY_PARAM_NAME,
} from '../constants';
import { AuthenticationModuleOptions } from '../interfaces';
@@ -18,15 +18,14 @@ export class CookieOptionsService {
get cookieName() {
return (
- this.authenticationOptions.cookies?.cookieName ||
- AUTHENTICATION_DEFAULT_COOKIE_NAME
+ this.authenticationOptions.cookies?.cookieName || DEFAULT_COOKIE_NAME
);
}
get queryParamName() {
return (
- this.authenticationOptions.cookies?.cookieName ||
- AUTHENTICATION_DEFAULT_QUERY_PARAM_NAME
+ this.authenticationOptions.cookies?.queryParamName ||
+ DEFAULT_URL_QUERY_PARAM_NAME
);
}
diff --git a/libs/nestjs/authentication/src/services/hash.service.spec.ts b/libs/nestjs/authentication/src/services/hash.service.spec.ts
index c428fb507..58407c1b5 100644
--- a/libs/nestjs/authentication/src/services/hash.service.spec.ts
+++ b/libs/nestjs/authentication/src/services/hash.service.spec.ts
@@ -2,9 +2,10 @@
import { Test, TestingModule } from '@nestjs/testing';
import { mockDeep, MockProxy, mockReset } from 'jest-mock-extended';
+import { HashService } from './hash.service';
import { MODULE_OPTIONS_TOKEN } from '../authentication.module-definition';
+import { ENCRYPTION_SERVICE } from '../constants';
import { AuthenticationModuleOptions } from '../interfaces';
-import { HashService } from './hash.service';
import { BcryptService } from '@trxn/nestjs-bcrypt';
@@ -12,12 +13,14 @@ describe('HashService', () => {
let hashService: HashService;
let mockAuthenticationModuleOptions: MockProxy;
let mockBcryptService: MockProxy;
+ let mockEncryptionService: MockProxy;
beforeEach(async () => {
mockAuthenticationModuleOptions = mockDeep(
{},
) as MockProxy;
mockBcryptService = mockDeep();
+ mockEncryptionService = mockDeep();
const module: TestingModule = await Test.createTestingModule({
providers: [
@@ -27,6 +30,10 @@ describe('HashService', () => {
useValue: mockAuthenticationModuleOptions,
},
{ provide: BcryptService, useValue: mockBcryptService },
+ {
+ provide: ENCRYPTION_SERVICE,
+ useValue: mockEncryptionService,
+ },
],
}).compile();
@@ -38,38 +45,75 @@ describe('HashService', () => {
mockReset(mockBcryptService);
});
- it('should be defined', () => {
- expect(hashService).toBeDefined();
- });
+ describe('use internal bcrypt provider', () => {
+ beforeEach(async () => {
+ mockAuthenticationModuleOptions = mockDeep(
+ {},
+ ) as MockProxy;
+ mockBcryptService = mockDeep();
+ mockEncryptionService = mockDeep();
- describe('compare', () => {
- it('should use the default BcryptService if no config is provided', async () => {
- mockAuthenticationModuleOptions.encryptionService = undefined;
- await hashService.compare('test', 'hash');
- expect(mockBcryptService.compare).toHaveBeenCalledWith('test', 'hash');
- });
- it('should use the EncryptionService if a config has been used', async () => {
- const encryptionService = mockDeep();
- mockAuthenticationModuleOptions.encryptionService = encryptionService;
+ const module: TestingModule = await Test.createTestingModule({
+ providers: [
+ HashService,
+ {
+ provide: MODULE_OPTIONS_TOKEN,
+ useValue: mockAuthenticationModuleOptions,
+ },
+ { provide: BcryptService, useValue: mockBcryptService },
+ ],
+ }).compile();
+ hashService = module.get(HashService);
+ });
+ it('should use the default BcryptService.compare', async () => {
await hashService.compare('test', 'hash');
- expect(mockBcryptService.compare).toHaveBeenCalledTimes(0);
- expect(encryptionService.compare).toHaveBeenCalledWith('test', 'hash');
+ expect(mockBcryptService.compare).toHaveBeenCalledWith('test', 'hash');
+ expect(mockEncryptionService.compare).not.toHaveBeenCalled();
});
- });
- describe('hash', () => {
- it('should use the default BcryptService if no config is provided', async () => {
- mockAuthenticationModuleOptions.encryptionService = undefined;
+ it('should use the default BcryptService.hash', async () => {
await hashService.hash('test');
expect(mockBcryptService.hash).toHaveBeenCalledWith('test');
+ expect(mockEncryptionService.hash).not.toHaveBeenCalled();
});
- it('should use the EncryptionService if a config has been used', async () => {
- const encryptionService = mockDeep();
- mockAuthenticationModuleOptions.encryptionService = encryptionService;
+ });
+ describe('use external encryption provider', () => {
+ beforeEach(async () => {
+ mockAuthenticationModuleOptions = mockDeep(
+ {},
+ ) as MockProxy;
+ mockBcryptService = mockDeep();
+ mockEncryptionService = mockDeep();
+ const module: TestingModule = await Test.createTestingModule({
+ providers: [
+ HashService,
+ {
+ provide: MODULE_OPTIONS_TOKEN,
+ useValue: mockAuthenticationModuleOptions,
+ },
+ { provide: BcryptService, useValue: mockBcryptService },
+ {
+ provide: ENCRYPTION_SERVICE,
+ useValue: mockEncryptionService,
+ },
+ ],
+ }).compile();
+
+ hashService = module.get(HashService);
+ });
+ it('should use the EncryptionService.compare', async () => {
+ await hashService.compare('test', 'hash');
+ expect(mockBcryptService.compare).not.toHaveBeenCalled();
+ expect(mockEncryptionService.compare).toHaveBeenCalledWith(
+ 'test',
+ 'hash',
+ );
+ });
+ it('should use the EncryptionService.hash', async () => {
await hashService.hash('test');
- expect(mockBcryptService.hash).toHaveBeenCalledTimes(0);
- expect(encryptionService.hash).toHaveBeenCalledWith('test');
+ expect(mockBcryptService.hash).not.toHaveBeenCalled();
+ expect(mockEncryptionService.hash).toHaveBeenCalledWith('test');
});
});
});
diff --git a/libs/nestjs/authentication/src/services/hash.service.ts b/libs/nestjs/authentication/src/services/hash.service.ts
index fa26b1bb1..b32a0dd65 100644
--- a/libs/nestjs/authentication/src/services/hash.service.ts
+++ b/libs/nestjs/authentication/src/services/hash.service.ts
@@ -1,22 +1,19 @@
-import { Inject, Injectable } from '@nestjs/common';
+import { Inject, Injectable, Optional } from '@nestjs/common';
-import { MODULE_OPTIONS_TOKEN } from '../authentication.module-definition';
-import { AuthenticationModuleOptions } from '../interfaces';
+import { ENCRYPTION_SERVICE } from '../constants';
import { BcryptService, EncryptionService } from '@trxn/nestjs-bcrypt';
@Injectable()
export class HashService implements EncryptionService {
constructor(
- @Inject(MODULE_OPTIONS_TOKEN)
- private readonly authenticationModuleOptions: AuthenticationModuleOptions,
private readonly bcryptService: BcryptService,
- ) {}
- get encryptionService(): EncryptionService {
- return (
- this.authenticationModuleOptions.encryptionService || this.bcryptService
- );
+ @Optional()
+ @Inject(ENCRYPTION_SERVICE)
+ private readonly encryptionService: EncryptionService,
+ ) {
+ this.encryptionService = this.encryptionService || this.bcryptService;
}
async hash(value: string): Promise {
diff --git a/libs/nestjs/authentication/src/services/index.ts b/libs/nestjs/authentication/src/services/index.ts
index 3d693780f..8e55874e7 100644
--- a/libs/nestjs/authentication/src/services/index.ts
+++ b/libs/nestjs/authentication/src/services/index.ts
@@ -2,4 +2,3 @@ export * from './authentication.service';
export * from './cookie-options.service';
export * from './hash.service';
export * from './strategy-options.service';
-export * from './user-authentication.service';
diff --git a/libs/nestjs/authentication/src/services/strategy-options.service.ts b/libs/nestjs/authentication/src/services/strategy-options.service.ts
index 62b5fab67..5c1a783c2 100644
--- a/libs/nestjs/authentication/src/services/strategy-options.service.ts
+++ b/libs/nestjs/authentication/src/services/strategy-options.service.ts
@@ -7,14 +7,17 @@ import {
} from 'passport-jwt';
import { IStrategyOptionsWithRequest as LocalStrategyOptions } from 'passport-local';
+import { JwtOptionsService } from './jwt-options.service';
import { MODULE_OPTIONS_TOKEN } from '../authentication.module-definition';
import {
- AUTHENTICATION_DEFAULT_COOKIE_NAME,
- AUTHENTICATION_DEFAULT_QUERY_PARAM_NAME,
+ DEFAULT_COOKIE_NAME,
+ DEFAULT_LOCAL_PASS_REQ_TO_CALLBACK,
+ DEFAULT_LOCAL_PASSWORD_FIELD,
+ DEFAULT_LOCAL_USERNAME_FIELD,
+ DEFAULT_URL_QUERY_PARAM_NAME,
} from '../constants';
import { fromHttpOnlySignedAndSecureCookies } from '../extractors';
import { AuthenticationModuleOptions } from '../interfaces';
-import { JwtOptionsService } from './jwt-options.service';
@Injectable()
export class StrategyOptionsService {
@@ -24,24 +27,12 @@ export class StrategyOptionsService {
private readonly jwtOptionsService: JwtOptionsService,
) {}
- private get fields() {
- return {
- id: 'id',
- login: 'email',
- password: 'password',
- ...(this.authenticationOptions.user?.fields || {}),
- };
- }
-
get localStrategyOptions(): LocalStrategyOptions {
- const { login, password } = this.fields;
- const strategyOptions = this.authenticationOptions.strategy?.local || {};
-
return {
- passReqToCallback: true,
- ...strategyOptions,
- usernameField: login,
- passwordField: password,
+ passReqToCallback: DEFAULT_LOCAL_PASS_REQ_TO_CALLBACK,
+ usernameField: DEFAULT_LOCAL_USERNAME_FIELD,
+ passwordField: DEFAULT_LOCAL_PASSWORD_FIELD,
+ ...this.authenticationOptions.strategy?.local,
};
}
@@ -55,11 +46,9 @@ export class StrategyOptionsService {
),
ignoreExpiration: false,
jwtFromRequest: ExtractJwt.fromExtractors([
- fromHttpOnlySignedAndSecureCookies(AUTHENTICATION_DEFAULT_COOKIE_NAME),
+ fromHttpOnlySignedAndSecureCookies(DEFAULT_COOKIE_NAME),
ExtractJwt.fromAuthHeaderAsBearerToken(),
- ExtractJwt.fromUrlQueryParameter(
- AUTHENTICATION_DEFAULT_QUERY_PARAM_NAME,
- ),
+ ExtractJwt.fromUrlQueryParameter(DEFAULT_URL_QUERY_PARAM_NAME),
]),
...passportJwtStrategyOptions,
};
diff --git a/libs/nestjs/authentication/src/services/user-authentication.service.ts b/libs/nestjs/authentication/src/services/user-authentication.service.ts
deleted file mode 100644
index 1be66d648..000000000
--- a/libs/nestjs/authentication/src/services/user-authentication.service.ts
+++ /dev/null
@@ -1,79 +0,0 @@
-import { Inject, Injectable, Logger } from '@nestjs/common';
-import { Prisma, User } from '@prisma/client';
-
-import { MODULE_OPTIONS_TOKEN } from '../authentication.module-definition';
-import { AuthenticationModuleOptions } from '../interfaces';
-
-import { LoggerService } from '@trxn/nestjs-core';
-
-@Injectable()
-export class UserAuthenticationService {
- constructor(
- @Inject(MODULE_OPTIONS_TOKEN)
- private readonly passwordConfig: AuthenticationModuleOptions,
- @Inject(Logger) private readonly logger: LoggerService,
- ) {
- logger.setContext(UserAuthenticationService.name);
- }
-
- private get userService() {
- if (!this.passwordConfig.userService)
- throw new Error('User service not configured');
-
- return this.passwordConfig.userService;
- }
-
- private get fields() {
- return {
- id: 'id',
- login: 'email',
- password: 'password',
- ...(this.passwordConfig.user?.fields || {}),
- };
- }
-
- async getUserFromLogin(login: string): Promise {
- this.logger.debug(`Getting user from login ${login}`);
- const user = await this.userService.findUnique({
- where: {
- [this.fields.login]: login,
- },
- });
-
- return user;
- }
-
- async getPasswordFromUser(user: User): Promise {
- this.logger.debug(`Getting user from id ${user.id}`);
- const password = (await this.userService.findUnique({
- where: {
- [this.fields.id]: user.id,
- },
- select: {
- [this.fields.password]: true,
- },
- })) as {
- password: string | null;
- } | null;
-
- return password ? password[this.fields.password as 'password'] : null;
- }
-
- async getUserFromId(
- id: string | number,
- select?: T,
- ) {
- this.logger.debug(`Getting user from id ${id}`);
- const user = await this.userService.findUnique<{
- where: Prisma.UserWhereUniqueInput;
- select: T | undefined;
- }>({
- where: {
- [this.fields.id]: id,
- },
- select,
- });
-
- return user;
- }
-}
diff --git a/libs/nestjs/authentication/src/strategies/jwt.strategy.ts b/libs/nestjs/authentication/src/strategies/jwt.strategy.ts
index 2ee1c87ba..ebcb01271 100644
--- a/libs/nestjs/authentication/src/strategies/jwt.strategy.ts
+++ b/libs/nestjs/authentication/src/strategies/jwt.strategy.ts
@@ -5,23 +5,27 @@ import { Strategy } from 'passport-jwt';
import { MODULE_OPTIONS_TOKEN } from '../authentication.module-definition';
import { JwtTokenPayload } from '../dtos';
import { AuthenticationModuleOptions } from '../interfaces';
-import { StrategyOptionsService, UserAuthenticationService } from '../services';
+import { StrategyOptionsService } from '../services';
+
+import { UserService } from '@trxn/nestjs-user';
@Injectable()
export class JwtStrategy extends PassportStrategy(Strategy) {
constructor(
- private readonly userAuthenticationService: UserAuthenticationService,
@Inject(MODULE_OPTIONS_TOKEN)
private readonly authenticationOptions: AuthenticationModuleOptions,
+
protected readonly strategyOptionsService: StrategyOptionsService,
+
+ private readonly userService: UserService,
) {
super(strategyOptionsService.jwtStrategyOptions);
}
async validate(payload: JwtTokenPayload) {
- const user = await this.userAuthenticationService.getUserFromId(
+ const user = await this.userService.findUserById(
payload.sub,
- this.authenticationOptions.user?.customSelect,
+ this.authenticationOptions.customSelect,
);
if (!user) {
diff --git a/libs/nestjs/bcrypt/CHANGELOG.md b/libs/nestjs/bcrypt/CHANGELOG.md
index 5e0d31f7f..524001b7e 100644
--- a/libs/nestjs/bcrypt/CHANGELOG.md
+++ b/libs/nestjs/bcrypt/CHANGELOG.md
@@ -2,6 +2,35 @@
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
+# [2.1.0-next.1](https://github.com/tractr/traxion/compare/v2.1.0-next.0...v2.1.0-next.1) (2023-02-27)
+
+
+
+# [2.1.0-next.0](https://github.com/tractr/traxion/compare/v2.0.13...v2.1.0-next.0) (2023-02-27)
+
+
+
+## [2.0.11-next.3](https://github.com/tractr/traxion/compare/v2.0.11-next.2...v2.0.11-next.3) (2023-02-22)
+
+
+
+## [2.0.11-next.2](https://github.com/tractr/traxion/compare/v2.0.11-next.1...v2.0.11-next.2) (2023-02-22)
+
+
+
+## [2.0.11-next.1](https://github.com/tractr/traxion/compare/v2.0.11-next.0...v2.0.11-next.1) (2023-02-22)
+
+
+
+## [2.0.11-next.0](https://github.com/tractr/traxion/compare/v2.0.10...v2.0.11-next.0) (2023-02-22)
+
+
+### Bug Fixes
+
+* update mailer to use mailjet v6 ([7db4aaf](https://github.com/tractr/traxion/commit/7db4aaf835f96c33f9d0be4e2bff503c925fc138))
+
+
+
## [2.0.13](https://github.com/tractr/traxion/compare/v2.0.12...v2.0.13) (2023-02-24)
diff --git a/libs/nestjs/bcrypt/package.json b/libs/nestjs/bcrypt/package.json
index ed8ce2889..6d6aefdca 100644
--- a/libs/nestjs/bcrypt/package.json
+++ b/libs/nestjs/bcrypt/package.json
@@ -1,6 +1,6 @@
{
"name": "@trxn/nestjs-bcrypt",
- "version": "2.0.13",
+ "version": "2.1.0-next.1",
"repository": {
"type": "git",
"url": "https://github.com/tractr/traxion"
diff --git a/libs/nestjs/bcrypt/src/services/hash.service.spec.ts b/libs/nestjs/bcrypt/src/services/hash.service.spec.ts
index cd8e5d82e..5ebdaeffd 100644
--- a/libs/nestjs/bcrypt/src/services/hash.service.spec.ts
+++ b/libs/nestjs/bcrypt/src/services/hash.service.spec.ts
@@ -3,9 +3,9 @@ import { Test, TestingModule } from '@nestjs/testing';
import * as bcrypt from 'bcrypt';
import { mockDeep, MockProxy, mockReset } from 'jest-mock-extended';
+import { BcryptService } from './bcrypt.service';
import { MODULE_OPTIONS_TOKEN } from '../bcrypt.module-definition';
import { BcryptModuleOptions } from '../interfaces';
-import { BcryptService } from './bcrypt.service';
describe('BcryptService', () => {
let bcryptService: BcryptService;
diff --git a/libs/nestjs/casl/CHANGELOG.md b/libs/nestjs/casl/CHANGELOG.md
index efc158595..2b94d3a23 100644
--- a/libs/nestjs/casl/CHANGELOG.md
+++ b/libs/nestjs/casl/CHANGELOG.md
@@ -2,6 +2,40 @@
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
+# [2.1.0-next.1](https://github.com/tractr/traxion/compare/v2.1.0-next.0...v2.1.0-next.1) (2023-02-27)
+
+
+
+# [2.1.0-next.0](https://github.com/tractr/traxion/compare/v2.0.13...v2.1.0-next.0) (2023-02-27)
+
+
+
+## [2.0.11-next.3](https://github.com/tractr/traxion/compare/v2.0.11-next.2...v2.0.11-next.3) (2023-02-22)
+
+
+
+## [2.0.11-next.2](https://github.com/tractr/traxion/compare/v2.0.11-next.1...v2.0.11-next.2) (2023-02-22)
+
+
+
+## [2.0.11-next.1](https://github.com/tractr/traxion/compare/v2.0.11-next.0...v2.0.11-next.1) (2023-02-22)
+
+
+
+## [2.0.11-next.0](https://github.com/tractr/traxion/compare/v2.0.10...v2.0.11-next.0) (2023-02-22)
+
+
+### Bug Fixes
+
+* resolve conversation and make the api start without settings env ([87d4465](https://github.com/tractr/traxion/commit/87d446509dd3c182c92a9d269dfbe24a826899ec))
+
+
+### Features
+
+* clean authentication modules ([99b7db6](https://github.com/tractr/traxion/commit/99b7db69cc4f885ac885d147043003448895d66d))
+
+
+
## [2.0.13](https://github.com/tractr/traxion/compare/v2.0.12...v2.0.13) (2023-02-24)
diff --git a/libs/nestjs/casl/mocks/casl-exception-endpoint-mock.controller.ts b/libs/nestjs/casl/mocks/casl-exception-endpoint-mock.controller.ts
index 1b4b53cc0..b0ec539e7 100644
--- a/libs/nestjs/casl/mocks/casl-exception-endpoint-mock.controller.ts
+++ b/libs/nestjs/casl/mocks/casl-exception-endpoint-mock.controller.ts
@@ -1,10 +1,10 @@
/* istanbul ignore file */
-import { Ability, ForbiddenError } from '@casl/ability';
+import { AbilityBuilder, ForbiddenError, PureAbility } from '@casl/ability';
+import { createPrismaAbility, PrismaQuery, Subjects } from '@casl/prisma';
import { Controller, Get } from '@nestjs/common';
import { Public } from '@trxn/nestjs-core';
-
-type Abilities = ['read', 'User'];
+import { User } from '@trxn/nestjs-user';
@Controller()
export class CaslExceptionEndpointMockController {
@@ -15,7 +15,17 @@ export class CaslExceptionEndpointMockController {
@Public()
@Get('/casl-forbidden-error')
caslForbiddenError() {
- const ability = new Ability();
+ type AppAbility = PureAbility<
+ [
+ string,
+ Subjects<{
+ User: User;
+ }>,
+ ],
+ PrismaQuery
+ >;
+ const builder = new AbilityBuilder(createPrismaAbility);
+ const ability = builder.build();
ForbiddenError.from(ability).throwUnlessCan('read', 'User');
}
diff --git a/libs/nestjs/casl/mocks/policy-handler-class.mock.ts b/libs/nestjs/casl/mocks/policy-handler-class.mock.ts
index dc854109c..cdcc254f7 100644
--- a/libs/nestjs/casl/mocks/policy-handler-class.mock.ts
+++ b/libs/nestjs/casl/mocks/policy-handler-class.mock.ts
@@ -1,16 +1,14 @@
-import { Inject, Injectable } from '@nestjs/common';
+import { Injectable } from '@nestjs/common';
-import { CaslOptions } from '../src';
-import { CASL_MODULE_OPTIONS } from '../src/casl.constant';
import { AppAbility } from './role-permission.mock';
+import { CaslAbilityFactoryService } from '../src';
import { PolicyHandler } from '@trxn/common';
@Injectable()
export class PolicyHandlerClass implements PolicyHandler {
constructor(
- @Inject(CASL_MODULE_OPTIONS)
- private readonly caslOptions: CaslOptions,
+ private readonly caslAbilityFactoryService: CaslAbilityFactoryService,
) {}
handle() {
diff --git a/libs/nestjs/casl/mocks/role-permission.mock.ts b/libs/nestjs/casl/mocks/role-permission.mock.ts
index 1a9f217bb..3625329ed 100644
--- a/libs/nestjs/casl/mocks/role-permission.mock.ts
+++ b/libs/nestjs/casl/mocks/role-permission.mock.ts
@@ -1,8 +1,13 @@
/* istanbul ignore file */
-import { Subjects as CaslPrismaSubjects, PrismaAbility } from '@casl/prisma';
+import { AbilityBuilder, PureAbility } from '@casl/ability';
+import { Subjects as CaslPrismaSubjects, PrismaQuery } from '@casl/prisma';
import { Prisma, UserRoles } from '@prisma/client';
-import { DefinePermissions } from '../src';
+import {
+ DefinePermissions,
+ DefinePublicPermissions,
+ RolePermissions,
+} from '../src/interfaces';
export type Roles = 'admin' | 'user' | 'guest';
@@ -27,14 +32,14 @@ export const Actions = {
MANAGE: 'manage',
} as const;
-export type Actions = typeof Actions[keyof typeof Actions];
+export type Actions = (typeof Actions)[keyof typeof Actions];
-export type AppAbility = PrismaAbility<[Actions, 'all' | Subjects]>;
-export const AppAbility = PrismaAbility;
+export type AppAbility = PureAbility<[string, 'all' | Subjects], PrismaQuery>;
-export const rolePermissions: Record<
+export const rolePermissions: RolePermissions<
UserRoles,
- DefinePermissions
+ AbilityBuilder,
+ User
> = {
// eslint-disable-next-line @typescript-eslint/no-empty-function
guest({ can }) {
@@ -49,3 +54,9 @@ export const rolePermissions: Record<
// eslint-disable-next-line @typescript-eslint/no-empty-function
custom() {},
};
+
+export const publicPermissions: DefinePublicPermissions<
+ AbilityBuilder
+> = ({ can }) => {
+ can('read', 'Tag');
+};
diff --git a/libs/nestjs/casl/package.json b/libs/nestjs/casl/package.json
index fe4fa25dc..8376271d7 100644
--- a/libs/nestjs/casl/package.json
+++ b/libs/nestjs/casl/package.json
@@ -1,6 +1,6 @@
{
"name": "@trxn/nestjs-casl",
- "version": "2.0.13",
+ "version": "2.1.0-next.1",
"repository": {
"type": "git",
"url": "https://github.com/tractr/traxion"
diff --git a/libs/nestjs/casl/src/casl.constant.ts b/libs/nestjs/casl/src/casl.constant.ts
deleted file mode 100644
index 092c7e403..000000000
--- a/libs/nestjs/casl/src/casl.constant.ts
+++ /dev/null
@@ -1 +0,0 @@
-export const CASL_MODULE_OPTIONS = 'CASL_MODULE_OPTIONS';
diff --git a/libs/nestjs/casl/src/casl.module-definition.ts b/libs/nestjs/casl/src/casl.module-definition.ts
new file mode 100644
index 000000000..2102304b0
--- /dev/null
+++ b/libs/nestjs/casl/src/casl.module-definition.ts
@@ -0,0 +1,17 @@
+import { ConfigurableModuleBuilder } from '@nestjs/common';
+
+import { UntypedCaslModuleOptions } from './interfaces';
+
+export const {
+ ConfigurableModuleClass,
+ MODULE_OPTIONS_TOKEN,
+ ASYNC_OPTIONS_TYPE,
+ OPTIONS_TYPE,
+} = new ConfigurableModuleBuilder().build();
+
+export type ExtractExtraModuleDefinitionOptions =
+ T extends UntypedCaslModuleOptions & Partial ? U : never;
+
+export type ExtraModuleDefinitionOptions = ExtractExtraModuleDefinitionOptions<
+ typeof OPTIONS_TYPE
+>;
diff --git a/libs/nestjs/casl/src/casl.module.spec.ts b/libs/nestjs/casl/src/casl.module.spec.ts
index 72bfb1c5c..653bdfb3f 100644
--- a/libs/nestjs/casl/src/casl.module.spec.ts
+++ b/libs/nestjs/casl/src/casl.module.spec.ts
@@ -4,15 +4,17 @@ import { Test, TestingModule } from '@nestjs/testing';
import { mockDeep, MockProxy } from 'jest-mock-extended';
import * as request from 'supertest';
-import { CaslEndPointMock } from '../mocks/casl-endpoint-mock.controller';
-import { mockAuthenticationGuard } from '../mocks/mock-authentication-guard';
-import { rolePermissions } from '../mocks/role-permission.mock';
-import { CASL_MODULE_OPTIONS } from './casl.constant';
import { CaslModule } from './casl.module';
+import { MODULE_OPTIONS_TOKEN } from './casl.module-definition';
import { PoliciesGuard } from './guards';
-import { CaslOptions } from './interfaces';
+import { UntypedCaslModuleOptions } from './interfaces';
+import { CaslEndPointMock } from '../mocks/casl-endpoint-mock.controller';
+import { mockAuthenticationGuard } from '../mocks/mock-authentication-guard';
+import {
+ publicPermissions,
+ rolePermissions,
+} from '../mocks/role-permission.mock';
-import { UserAuthenticationService } from '@trxn/nestjs-authentication';
import { LoggerModule } from '@trxn/nestjs-core';
describe('Authentication Module', () => {
@@ -21,7 +23,6 @@ describe('Authentication Module', () => {
getUser: () => Record | null;
isPublic: () => boolean;
}>;
- const mockAuthenticationUserService = mockDeep();
beforeAll(async () => {
mockUser = mockDeep<{
@@ -42,15 +43,13 @@ describe('Authentication Module', () => {
provide: APP_GUARD,
useClass: PoliciesGuard,
},
- {
- provide: UserAuthenticationService,
- useValue: mockAuthenticationUserService,
- },
],
imports: [
LoggerModule,
CaslModule.register({
rolePermissions,
+ getRoles: (user) => user.roles,
+ publicPermissions,
}),
],
}).compile();
@@ -86,7 +85,8 @@ describe('Authentication Module', () => {
roles: ['guest'],
});
await request(app.getHttpServer()).get('/read-user').expect(403);
-
+ });
+ it('/read-user no-user', async () => {
mockUser.getUser.mockReturnValue(null);
mockUser.isPublic.mockReturnValueOnce(true);
@@ -112,7 +112,8 @@ describe('Authentication Module', () => {
roles: ['guest'],
});
await request(app.getHttpServer()).get('/read-admin').expect(403);
-
+ });
+ it('/read-admin no-user', async () => {
mockUser.getUser.mockReturnValue(null);
mockUser.isPublic.mockReturnValueOnce(true);
@@ -138,7 +139,8 @@ describe('Authentication Module', () => {
roles: ['guest'],
});
await request(app.getHttpServer()).get('/read-guest').expect(200);
-
+ });
+ it('/read-guest no-user', async () => {
mockUser.getUser.mockReturnValue(null);
mockUser.isPublic.mockReturnValueOnce(true);
@@ -199,23 +201,21 @@ describe('Authentication Module', () => {
provide: APP_GUARD,
useClass: PoliciesGuard,
},
- {
- provide: UserAuthenticationService,
- useValue: mockAuthenticationUserService,
- },
],
imports: [
LoggerModule,
CaslModule.registerAsync({
useFactory: () => ({
rolePermissions,
+ getRoles: (user) => user.roles,
+ publicPermissions,
}),
}),
],
}).compile();
const caslModuleOptions =
- moduleFixture.get(CASL_MODULE_OPTIONS);
+ moduleFixture.get(MODULE_OPTIONS_TOKEN);
expect(caslModuleOptions.rolePermissions).toEqual(rolePermissions);
});
diff --git a/libs/nestjs/casl/src/casl.module.ts b/libs/nestjs/casl/src/casl.module.ts
index aad1d8ab7..3157f6c1b 100644
--- a/libs/nestjs/casl/src/casl.module.ts
+++ b/libs/nestjs/casl/src/casl.module.ts
@@ -1,12 +1,20 @@
-import { AnyAbility } from '@casl/ability';
-import { DynamicModule, Module } from '@nestjs/common';
+import { AbilityBuilder, AnyAbility } from '@casl/ability';
+import {
+ ConfigurableModuleAsyncOptions,
+ DynamicModule,
+ Module,
+} from '@nestjs/common';
-import { CASL_MODULE_OPTIONS } from './casl.constant';
-import { CaslOptions } from './interfaces';
+import {
+ ASYNC_OPTIONS_TYPE,
+ ConfigurableModuleClass,
+ ExtraModuleDefinitionOptions,
+ OPTIONS_TYPE,
+} from './casl.module-definition';
+import { CaslModuleOptions } from './interfaces';
import { CaslAbilityFactoryService } from './services/casl.service';
import { AuthenticationModule } from '@trxn/nestjs-authentication';
-import { AsyncOptions, ModuleOptionsFactory } from '@trxn/nestjs-core';
@Module({
imports: [AuthenticationModule],
@@ -14,18 +22,26 @@ import { AsyncOptions, ModuleOptionsFactory } from '@trxn/nestjs-core';
providers: [CaslAbilityFactoryService],
exports: [CaslAbilityFactoryService],
})
-export class CaslModule extends ModuleOptionsFactory(
- CASL_MODULE_OPTIONS,
-) {
- static register(
- options: CaslOptions,
+export class CaslModule extends ConfigurableModuleClass {
+ static register<
+ R extends string,
+ U extends Record,
+ B extends AbilityBuilder,
+ >(
+ options: CaslModuleOptions & ExtraModuleDefinitionOptions,
): DynamicModule {
- return super.register(options as CaslOptions);
+ return super.register(options as unknown as typeof OPTIONS_TYPE);
}
- static registerAsync(
- options: AsyncOptions>,
+ static registerAsync<
+ R extends string,
+ U extends Record,
+ B extends AbilityBuilder,
+ >(
+ options: ConfigurableModuleAsyncOptions<
+ CaslModuleOptions & ExtraModuleDefinitionOptions
+ >,
): DynamicModule {
- return super.registerAsync(options as AsyncOptions);
+ return super.registerAsync(options as typeof ASYNC_OPTIONS_TYPE);
}
}
diff --git a/libs/nestjs/casl/src/configs/casl.config.ts b/libs/nestjs/casl/src/configs/casl.config.ts
deleted file mode 100644
index aefbd22f4..000000000
--- a/libs/nestjs/casl/src/configs/casl.config.ts
+++ /dev/null
@@ -1 +0,0 @@
-export const CASL_OPTIONS = {};
diff --git a/libs/nestjs/casl/src/configs/index.ts b/libs/nestjs/casl/src/configs/index.ts
deleted file mode 100644
index 698ae49f9..000000000
--- a/libs/nestjs/casl/src/configs/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from './casl.config';
diff --git a/libs/nestjs/casl/src/guards/policies-guard.ts b/libs/nestjs/casl/src/guards/policies-guard.ts
index 3e9c7f94a..73862cfcd 100644
--- a/libs/nestjs/casl/src/guards/policies-guard.ts
+++ b/libs/nestjs/casl/src/guards/policies-guard.ts
@@ -5,12 +5,12 @@ import {
Injectable,
} from '@nestjs/common';
import { ModuleRef, Reflector } from '@nestjs/core';
-import type { User } from '@prisma/client';
import { CaslAbilityFactoryService } from '../services';
import { isClass, PolicyHandlerType } from '@trxn/common';
import { getRequestFromContext, POLICIES_KEY } from '@trxn/nestjs-core';
+import { MinimalUser, User } from '@trxn/nestjs-user';
@Injectable()
export class PoliciesGuard implements CanActivate {
@@ -20,7 +20,9 @@ export class PoliciesGuard implements CanActivate {
private caslAbilityFactory: CaslAbilityFactoryService,
) {}
- async canActivate(context: ExecutionContext): Promise {
+ async canActivate(
+ context: ExecutionContext,
+ ): Promise {
const policyHandlers =
this.reflector.get[]>(
POLICIES_KEY,
@@ -37,10 +39,14 @@ export class PoliciesGuard implements CanActivate {
// Get user from the request object.
// User should have been fetched and hydrated by the authentication layer
- const { user }: { user?: User } = req;
-
- if (user && (!user.roles || !Array.isArray(user.roles))) {
- throw new ForbiddenException();
+ const { user }: { user?: U } = req;
+
+ if (user) {
+ try {
+ this.caslAbilityFactory.getRoles(user);
+ } catch {
+ throw new ForbiddenException();
+ }
}
const ability = this.caslAbilityFactory.createForUser(user);
diff --git a/libs/nestjs/casl/src/index.ts b/libs/nestjs/casl/src/index.ts
index 329e85f94..fad654c1d 100644
--- a/libs/nestjs/casl/src/index.ts
+++ b/libs/nestjs/casl/src/index.ts
@@ -1,4 +1,3 @@
-export * from './configs';
export * from './guards';
export * from './interceptors';
export * from './interfaces';
diff --git a/libs/nestjs/casl/src/interceptors/casl-exception.interceptor.spec.ts b/libs/nestjs/casl/src/interceptors/casl-exception.interceptor.spec.ts
index 05cbcc03f..5c1f8a3f7 100644
--- a/libs/nestjs/casl/src/interceptors/casl-exception.interceptor.spec.ts
+++ b/libs/nestjs/casl/src/interceptors/casl-exception.interceptor.spec.ts
@@ -3,8 +3,8 @@ import { APP_INTERCEPTOR } from '@nestjs/core';
import { Test, TestingModule } from '@nestjs/testing';
import * as request from 'supertest';
-import { CaslExceptionEndpointMockController } from '../../mocks/casl-exception-endpoint-mock.controller';
import { CaslExceptionInterceptor } from './casl-exception.interceptor';
+import { CaslExceptionEndpointMockController } from '../../mocks/casl-exception-endpoint-mock.controller';
describe('Casl exception error', () => {
let app: INestApplication;
diff --git a/libs/nestjs/casl/src/interfaces/casl.interface.ts b/libs/nestjs/casl/src/interfaces/casl.interface.ts
index ab5661efc..9dcf29662 100644
--- a/libs/nestjs/casl/src/interfaces/casl.interface.ts
+++ b/libs/nestjs/casl/src/interfaces/casl.interface.ts
@@ -1,16 +1,33 @@
+/* eslint-disable @typescript-eslint/no-explicit-any */
import { AbilityBuilder, AnyAbility } from '@casl/ability';
-import { PrismaAbility as CaslPrismaAbilities } from '@casl/prisma';
-import { Prisma, User, UserRoles } from '@prisma/client';
-export interface CaslOptions {
- rolePermissions: Record>;
-}
-
-export type PrismaAbility = CaslPrismaAbilities<
- [string, 'all' | Prisma.ModelName]
->;
+export type DefinePermissions, U> = (
+ ability: B,
+ user: U,
+) => void;
-export type DefinePermissions = (
- ability: AbilityBuilder,
- user?: User,
+export type DefinePublicPermissions> = (
+ ability: B,
) => void;
+
+export type RolePermissions<
+ R extends string,
+ B extends AbilityBuilder,
+ U extends Record,
+> = Record>;
+
+export type CaslModuleOptions<
+ R extends string,
+ U extends Record,
+ B extends AbilityBuilder,
+> = {
+ rolePermissions: Record>;
+ getRoles: (user: U) => R[];
+ publicPermissions?: DefinePublicPermissions;
+};
+
+export type UntypedCaslModuleOptions = CaslModuleOptions<
+ string,
+ Record,
+ AbilityBuilder
+>;
diff --git a/libs/nestjs/casl/src/services/casl.service.spec.ts b/libs/nestjs/casl/src/services/casl.service.spec.ts
index 26cf26df9..204ccdf9b 100644
--- a/libs/nestjs/casl/src/services/casl.service.spec.ts
+++ b/libs/nestjs/casl/src/services/casl.service.spec.ts
@@ -1,26 +1,46 @@
-import { PrismaAbility } from '@casl/prisma';
+import { AbilityBuilder, AnyAbility } from '@casl/ability';
import { UnauthorizedException } from '@nestjs/common';
import { Test, TestingModule } from '@nestjs/testing';
-import type { User } from '@prisma/client';
import { mockDeep, MockProxy } from 'jest-mock-extended';
-import { AppAbility, rolePermissions } from '../../mocks/role-permission.mock';
-import { CASL_MODULE_OPTIONS } from '../casl.constant';
-import { CaslOptions } from '../interfaces';
import { CaslAbilityFactoryService } from './casl.service';
+import {
+ publicPermissions,
+ rolePermissions,
+} from '../../mocks/role-permission.mock';
+import { MODULE_OPTIONS_TOKEN } from '../casl.module-definition';
+import {
+ DefinePublicPermissions,
+ RolePermissions,
+ UntypedCaslModuleOptions,
+} from '../interfaces';
describe('CaslService', () => {
let caslAbilityFactoryService: CaslAbilityFactoryService;
- let mockCaslOptions: MockProxy>;
+ let mockCaslOptions: MockProxy;
beforeEach(async () => {
- mockCaslOptions = mockDeep>();
+ mockCaslOptions = mockDeep(
+ {
+ funcPropSupport: true,
+ },
+ {
+ rolePermissions: mockDeep(
+ rolePermissions,
+ ) as unknown as RolePermissions<
+ string,
+ AbilityBuilder,
+ Record
+ >,
+ getRoles: (user) => user.roles as string[],
+ },
+ );
const moduleFixture: TestingModule = await Test.createTestingModule({
providers: [
CaslAbilityFactoryService,
{
- provide: CASL_MODULE_OPTIONS,
+ provide: MODULE_OPTIONS_TOKEN,
useValue: mockCaslOptions,
},
],
@@ -37,56 +57,52 @@ describe('CaslService', () => {
describe('createForUser', () => {
it('should create a abitily from a rolePermission configuration', async () => {
- mockCaslOptions.rolePermissions = mockDeep(rolePermissions);
-
const userAdmin = {
id: 'admin',
roles: ['admin'],
- } as User;
+ };
const abilities = caslAbilityFactoryService.createForUser(userAdmin);
expect(abilities).toBeDefined();
- expect(abilities).toBeInstanceOf(PrismaAbility);
});
- it('should throw an error if no user is passed and no guest permissions is defined', async () => {
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
- const { guest, ...permissionsWithoutGuest } = rolePermissions;
-
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- mockCaslOptions.rolePermissions = permissionsWithoutGuest as any;
-
- expect(() => caslAbilityFactoryService.createForUser(undefined)).toThrow(
+ it('should throw an error if no user is passed and no publicPermissions are defined', async () => {
+ mockCaslOptions.publicPermissions = undefined;
+ expect(() => caslAbilityFactoryService.createForUser()).toThrow(
UnauthorizedException,
);
});
+ it('should not throw an error if no user is passed and but a publicPermissions is used', async () => {
+ mockCaslOptions.publicPermissions =
+ publicPermissions as unknown as DefinePublicPermissions<
+ AbilityBuilder
+ >;
+
+ const abilities = caslAbilityFactoryService.createForUser();
+ expect(abilities).toBeDefined();
+ });
+
it('should configure no access if a role does not exists', async () => {
- mockCaslOptions.rolePermissions = mockDeep(rolePermissions);
+ mockCaslOptions.rolePermissions = mockDeep(
+ rolePermissions,
+ ) as unknown as RolePermissions<
+ string,
+ AbilityBuilder,
+ Record
+ >;
const userWithAWrongRole = {
id: 'admin',
roles: ['not-exists'],
- } as unknown as User;
+ };
const abilities =
caslAbilityFactoryService.createForUser(userWithAWrongRole);
expect(abilities).toBeDefined();
- expect(abilities).toBeInstanceOf(PrismaAbility);
expect(abilities.cannot('manage', 'all')).toEqual(true);
});
-
- it('should default to the guest role if no user is provided', async () => {
- mockCaslOptions.rolePermissions = mockDeep(rolePermissions);
-
- const abilities = caslAbilityFactoryService.createForUser();
-
- expect(abilities).toBeDefined();
- expect(abilities).toBeInstanceOf(PrismaAbility);
- expect(abilities.can('read', 'Tag')).toEqual(true);
- expect(abilities.cannot('read', 'User')).toEqual(true);
- });
});
});
diff --git a/libs/nestjs/casl/src/services/casl.service.ts b/libs/nestjs/casl/src/services/casl.service.ts
index 6f1e7eeb4..a1e6ba2ad 100644
--- a/libs/nestjs/casl/src/services/casl.service.ts
+++ b/libs/nestjs/casl/src/services/casl.service.ts
@@ -1,27 +1,34 @@
-import { AbilityBuilder, Subject } from '@casl/ability';
-import { PrismaAbility } from '@casl/prisma';
+import { AbilityBuilder } from '@casl/ability';
+import { createPrismaAbility } from '@casl/prisma';
import { Inject, Injectable, UnauthorizedException } from '@nestjs/common';
-import type { Prisma, User } from '@prisma/client';
-import { CASL_MODULE_OPTIONS } from '../casl.constant';
-import { CaslOptions } from '../interfaces';
+import { MODULE_OPTIONS_TOKEN } from '../casl.module-definition';
+import { UntypedCaslModuleOptions } from '../interfaces';
+
+import { User } from '@trxn/nestjs-user';
@Injectable()
export class CaslAbilityFactoryService {
constructor(
- @Inject(CASL_MODULE_OPTIONS)
- private readonly caslOptions: CaslOptions,
+ @Inject(MODULE_OPTIONS_TOKEN)
+ private readonly caslOptions: UntypedCaslModuleOptions,
) {}
- createForUser(user?: User): PrismaAbility<[string, 'all' | Subject]> {
- const builder = new AbilityBuilder<
- PrismaAbility<[string, 'all' | Prisma.ModelName]>
- >(PrismaAbility);
+ getRoles(user: Record) {
+ const roles = this.caslOptions.getRoles(user);
+ if (!Array.isArray(roles)) {
+ throw new Error('getRoles must return an array of roles');
+ }
+ return roles;
+ }
+
+ createForUser(user?: U) {
+ const builder = new AbilityBuilder(createPrismaAbility);
- const { rolePermissions } = this.caslOptions;
+ const { rolePermissions, publicPermissions } = this.caslOptions;
- if (!user && rolePermissions.guest) {
- rolePermissions.guest(builder, user);
+ if (!user && publicPermissions) {
+ publicPermissions(builder);
return builder.build();
}
@@ -29,14 +36,18 @@ export class CaslAbilityFactoryService {
throw new UnauthorizedException();
}
- user.roles.forEach((role) => {
- if (!rolePermissions[role]) return;
- rolePermissions[role](builder, user);
- });
+ const roles = this.getRoles(user);
+
+ let hasSomeRole = false;
+ for (const role of roles) {
+ if (rolePermissions[role]) {
+ hasSomeRole = true;
+ rolePermissions[role](builder, user);
+ }
+ }
- if (
- user.roles.some((role) => typeof rolePermissions[role] === 'undefined')
- ) {
+ // If the user has no role, they cannot do anything.
+ if (!hasSomeRole) {
builder.cannot('manage', 'all');
}
diff --git a/libs/nestjs/core/CHANGELOG.md b/libs/nestjs/core/CHANGELOG.md
index 2f63d0e52..e24374fda 100644
--- a/libs/nestjs/core/CHANGELOG.md
+++ b/libs/nestjs/core/CHANGELOG.md
@@ -2,6 +2,40 @@
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
+# [2.1.0-next.1](https://github.com/tractr/traxion/compare/v2.1.0-next.0...v2.1.0-next.1) (2023-02-27)
+
+
+
+# [2.1.0-next.0](https://github.com/tractr/traxion/compare/v2.0.13...v2.1.0-next.0) (2023-02-27)
+
+
+
+## [2.0.11-next.3](https://github.com/tractr/traxion/compare/v2.0.11-next.2...v2.0.11-next.3) (2023-02-22)
+
+
+
+## [2.0.11-next.2](https://github.com/tractr/traxion/compare/v2.0.11-next.1...v2.0.11-next.2) (2023-02-22)
+
+
+
+## [2.0.11-next.1](https://github.com/tractr/traxion/compare/v2.0.11-next.0...v2.0.11-next.1) (2023-02-22)
+
+
+
+## [2.0.11-next.0](https://github.com/tractr/traxion/compare/v2.0.10...v2.0.11-next.0) (2023-02-22)
+
+
+### Bug Fixes
+
+* update mailer to use mailjet v6 ([2a4a060](https://github.com/tractr/traxion/commit/2a4a0607963235cbb859e8ff99794829f7eaaf58))
+
+
+### Features
+
+* clean authentication modules ([99b7db6](https://github.com/tractr/traxion/commit/99b7db69cc4f885ac885d147043003448895d66d))
+
+
+
## [2.0.13](https://github.com/tractr/traxion/compare/v2.0.12...v2.0.13) (2023-02-24)
diff --git a/libs/nestjs/core/mocks/prisma-exception-endpoint-mock.controller.ts b/libs/nestjs/core/mocks/prisma-exception-endpoint-mock.controller.ts
index 33cea6c32..b11aba97e 100644
--- a/libs/nestjs/core/mocks/prisma-exception-endpoint-mock.controller.ts
+++ b/libs/nestjs/core/mocks/prisma-exception-endpoint-mock.controller.ts
@@ -1,15 +1,12 @@
import { Controller, Get } from '@nestjs/common';
import { Prisma } from '@prisma/client';
-import { Public } from '../src/decorators/public.decorator';
-
@Controller()
export class PrismaExceptionEndpointMockController {
private readonly ERROR_MESSAGE = 'This is an example error message';
private readonly ERROR_CLIENT_VERSION = '1.0.0';
- @Public()
@Get('/known-request-error-not-found')
knownRequestErrorNotFound(): Prisma.PrismaClientKnownRequestError {
throw new Prisma.PrismaClientKnownRequestError(this.ERROR_MESSAGE, {
@@ -18,7 +15,6 @@ export class PrismaExceptionEndpointMockController {
});
}
- @Public()
@Get('/known-request-error-conflict')
knownRequestErrorConflict(): Prisma.PrismaClientKnownRequestError {
throw new Prisma.PrismaClientKnownRequestError(this.ERROR_MESSAGE, {
@@ -27,7 +23,6 @@ export class PrismaExceptionEndpointMockController {
});
}
- @Public()
@Get('/initialization-error-not-found')
initializationErrorNotFound(): Prisma.PrismaClientInitializationError {
throw new Prisma.PrismaClientInitializationError(
@@ -37,13 +32,11 @@ export class PrismaExceptionEndpointMockController {
);
}
- @Public()
@Get('/client-validation-error')
clientValidationError(): Prisma.PrismaClientValidationError {
throw new Prisma.PrismaClientValidationError(this.ERROR_MESSAGE);
}
- @Public()
@Get('/initialization-error-conflict')
initializationErrorConflict(): Prisma.PrismaClientInitializationError {
throw new Prisma.PrismaClientInitializationError(
@@ -53,7 +46,6 @@ export class PrismaExceptionEndpointMockController {
);
}
- @Public()
@Get('/unknown-request-error')
unknownRequestError(): Prisma.PrismaClientUnknownRequestError {
throw new Prisma.PrismaClientUnknownRequestError(this.ERROR_MESSAGE, {
@@ -61,7 +53,6 @@ export class PrismaExceptionEndpointMockController {
});
}
- @Public()
@Get('/client-rust-panic-error')
clientRustPanicError(): Prisma.PrismaClientRustPanicError {
throw new Prisma.PrismaClientRustPanicError(
@@ -70,7 +61,6 @@ export class PrismaExceptionEndpointMockController {
);
}
- @Public()
@Get('/default-error')
defaultError(): Error {
throw new Error(this.ERROR_MESSAGE);
diff --git a/libs/nestjs/core/package.json b/libs/nestjs/core/package.json
index 944c19294..b58dda98d 100644
--- a/libs/nestjs/core/package.json
+++ b/libs/nestjs/core/package.json
@@ -1,6 +1,6 @@
{
"name": "@trxn/nestjs-core",
- "version": "2.0.13",
+ "version": "2.1.0-next.1",
"description": "Core module for nestjs backend",
"repository": {
"type": "git",
diff --git a/libs/nestjs/core/src/helpers/index.ts b/libs/nestjs/core/src/helpers/index.ts
index 90bc560ff..37eeada9e 100644
--- a/libs/nestjs/core/src/helpers/index.ts
+++ b/libs/nestjs/core/src/helpers/index.ts
@@ -2,6 +2,7 @@ export * from './context.helper';
export * from './format-entity-ids';
export * from './format-filter-type';
export * from './format-sort';
+export * from './set-extras.helper';
export * from './is-development.helper';
export * from './is-production.helper';
export * from './module-options.helper';
diff --git a/libs/nestjs/core/src/helpers/module-options.helper.ts b/libs/nestjs/core/src/helpers/module-options.helper.ts
index 5e0d95d51..1531d06f4 100644
--- a/libs/nestjs/core/src/helpers/module-options.helper.ts
+++ b/libs/nestjs/core/src/helpers/module-options.helper.ts
@@ -68,6 +68,8 @@ export type AsyncOptions<
/**
* The ModuleOptionsHelper that need to be extends to get access
* to the register registerAsync forRoot and forRootAsync
+ *
+ * @deprecated Use the ConfigurableModuleBuilder from nestjs instead
*/
export function ModuleOptionsFactory<
InternalOptions,
diff --git a/libs/nestjs/core/src/helpers/set-extras.helper.ts b/libs/nestjs/core/src/helpers/set-extras.helper.ts
new file mode 100644
index 000000000..b14065d78
--- /dev/null
+++ b/libs/nestjs/core/src/helpers/set-extras.helper.ts
@@ -0,0 +1,94 @@
+/* eslint-disable @typescript-eslint/no-explicit-any */
+import {
+ DynamicModule,
+ ForwardReference,
+ InjectionToken,
+ Provider,
+ Type,
+} from '@nestjs/common';
+
+import type { ProviderWithInjectionToken } from '../interfaces';
+
+export type ImportsExtra = {
+ imports: Array<
+ Type | DynamicModule | Promise | ForwardReference
+ >;
+};
+
+export type ProvidersExtra = {
+ providers?: Provider[] | undefined;
+};
+
+export function addImportsExtra(
+ transformDefinition: (
+ definition: DynamicModule,
+ extras: Omit,
+ ) => DynamicModule,
+) {
+ return (definition: DynamicModule, { imports, ...extras }: E) =>
+ transformDefinition(
+ {
+ ...definition,
+ imports: [...(definition.imports || []), ...(imports || [])],
+ },
+ extras,
+ );
+}
+
+export function addProvidersExtra(
+ transformDefinition: (
+ definition: DynamicModule,
+ extras: Omit,
+ ) => DynamicModule,
+) {
+ return (definition: DynamicModule, { providers, ...extras }: E) =>
+ transformDefinition(
+ {
+ ...definition,
+ providers: [...(definition.providers || []), ...(providers || [])],
+ },
+ extras,
+ );
+}
+
+export function addImportsAndProvidersExtra<
+ E extends ImportsExtra & ProvidersExtra,
+>(
+ transformDefinition: (
+ definition: DynamicModule,
+ extras: Omit,
+ ) => DynamicModule,
+) {
+ return (definition: DynamicModule, { imports, providers, ...extras }: E) =>
+ transformDefinition(
+ {
+ ...definition,
+ imports: [...(definition.imports || []), ...(imports || [])],
+ providers: [...(definition.providers || []), ...(providers || [])],
+ },
+ extras,
+ );
+}
+
+export function addProviderWithInjectionTokenExtra(
+ definition: DynamicModule,
+ token: I,
+ providerWithToken?: ProviderWithInjectionToken,
+) {
+ if (!providerWithToken) {
+ return definition;
+ }
+
+ let provider: Provider = providerWithToken;
+ if (!('provide' in provider)) {
+ provider = {
+ provide: token,
+ useClass: provider,
+ };
+ }
+
+ return {
+ ...definition,
+ providers: [...(definition.providers || []), provider],
+ };
+}
diff --git a/libs/nestjs/core/src/index.ts b/libs/nestjs/core/src/index.ts
index 8ed8145bc..eaf882c50 100644
--- a/libs/nestjs/core/src/index.ts
+++ b/libs/nestjs/core/src/index.ts
@@ -1,6 +1,7 @@
export * from './decorators';
export * from './helpers';
export * from './interceptors';
+export * from './interfaces';
export * from './pipes';
export * from './services';
export * from './logger.module';
diff --git a/libs/nestjs/core/src/interceptors/prisma-exception.interceptor.spec.ts b/libs/nestjs/core/src/interceptors/prisma-exception.interceptor.spec.ts
index 64e77f512..4273b9f8d 100644
--- a/libs/nestjs/core/src/interceptors/prisma-exception.interceptor.spec.ts
+++ b/libs/nestjs/core/src/interceptors/prisma-exception.interceptor.spec.ts
@@ -3,13 +3,13 @@ import { APP_INTERCEPTOR } from '@nestjs/core';
import { Test, TestingModule } from '@nestjs/testing';
import * as request from 'supertest';
-import { PrismaExceptionEndpointMockController } from '../../mocks/prisma-exception-endpoint-mock.controller';
import { PrismaExceptionInterceptor } from './prisma-exception.interceptor';
+import { PrismaExceptionEndpointMockController } from '../../mocks/prisma-exception-endpoint-mock.controller';
describe('Prisma exception error', () => {
let app: INestApplication;
- beforeEach(async () => {
+ beforeAll(async () => {
const moduleFixture: TestingModule = await Test.createTestingModule({
controllers: [PrismaExceptionEndpointMockController],
providers: [
@@ -25,7 +25,7 @@ describe('Prisma exception error', () => {
await app.init();
});
- afterEach(async () => {
+ afterAll(async () => {
if (app) await app.close();
});
diff --git a/libs/nestjs/core/src/interfaces/index.ts b/libs/nestjs/core/src/interfaces/index.ts
new file mode 100644
index 000000000..7a0ef4849
--- /dev/null
+++ b/libs/nestjs/core/src/interfaces/index.ts
@@ -0,0 +1 @@
+export * from './set-extras-providers.interfaces';
diff --git a/libs/nestjs/core/src/interfaces/set-extras-providers.interfaces.ts b/libs/nestjs/core/src/interfaces/set-extras-providers.interfaces.ts
new file mode 100644
index 000000000..22fea8094
--- /dev/null
+++ b/libs/nestjs/core/src/interfaces/set-extras-providers.interfaces.ts
@@ -0,0 +1,33 @@
+/* eslint-disable @typescript-eslint/no-explicit-any */
+import {
+ ClassProvider,
+ ExistingProvider,
+ FactoryProvider,
+ InjectionToken,
+ Type,
+ ValueProvider,
+} from '@nestjs/common';
+
+export type ClassProviderWithInjectionToken<
+ I = InjectionToken,
+ T = any,
+> = ClassProvider & { provide: I };
+export type ValueProviderWithInjectionToken<
+ I = InjectionToken,
+ T = any,
+> = ValueProvider & { provide: I };
+export type FactoryProviderWithInjectionToken<
+ I = InjectionToken,
+ T = any,
+> = FactoryProvider & { provide: I };
+export type ExistingProviderWithInjectionToken<
+ I = InjectionToken,
+ T = any,
+> = ExistingProvider & { provide: I };
+
+export type ProviderWithInjectionToken =
+ | Type
+ | ClassProviderWithInjectionToken
+ | ValueProviderWithInjectionToken
+ | FactoryProviderWithInjectionToken
+ | ExistingProviderWithInjectionToken;
diff --git a/libs/nestjs/core/src/services/logger.service.spec.ts b/libs/nestjs/core/src/services/logger.service.spec.ts
index b0117cb21..685319a27 100644
--- a/libs/nestjs/core/src/services/logger.service.spec.ts
+++ b/libs/nestjs/core/src/services/logger.service.spec.ts
@@ -3,6 +3,10 @@ import { Test, TestingModule } from '@nestjs/testing';
import { LoggerService } from './logger.service';
+const noop = () => {
+ // nothing
+};
+
describe('loggerService', () => {
let loggerService: LoggerService;
let verbose: jest.SpyInstance;
@@ -12,11 +16,11 @@ describe('loggerService', () => {
let error: jest.SpyInstance;
beforeEach(async () => {
- verbose = jest.spyOn(Logger.prototype, 'verbose');
- debug = jest.spyOn(Logger.prototype, 'debug');
- log = jest.spyOn(Logger.prototype, 'log');
- warn = jest.spyOn(Logger.prototype, 'warn');
- error = jest.spyOn(Logger.prototype, 'error');
+ verbose = jest.spyOn(Logger.prototype, 'verbose').mockImplementation(noop);
+ debug = jest.spyOn(Logger.prototype, 'debug').mockImplementation(noop);
+ log = jest.spyOn(Logger.prototype, 'log').mockImplementation(noop);
+ warn = jest.spyOn(Logger.prototype, 'warn').mockImplementation(noop);
+ error = jest.spyOn(Logger.prototype, 'error').mockImplementation(noop);
const module: TestingModule = await Test.createTestingModule({
providers: [LoggerService],
diff --git a/libs/nestjs/database/CHANGELOG.md b/libs/nestjs/database/CHANGELOG.md
index 7a8b85ce7..ac761f676 100644
--- a/libs/nestjs/database/CHANGELOG.md
+++ b/libs/nestjs/database/CHANGELOG.md
@@ -2,6 +2,35 @@
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
+# [2.1.0-next.1](https://github.com/tractr/traxion/compare/v2.1.0-next.0...v2.1.0-next.1) (2023-02-27)
+
+
+
+# [2.1.0-next.0](https://github.com/tractr/traxion/compare/v2.0.13...v2.1.0-next.0) (2023-02-27)
+
+
+
+## [2.0.11-next.3](https://github.com/tractr/traxion/compare/v2.0.11-next.2...v2.0.11-next.3) (2023-02-22)
+
+
+
+## [2.0.11-next.2](https://github.com/tractr/traxion/compare/v2.0.11-next.1...v2.0.11-next.2) (2023-02-22)
+
+
+
+## [2.0.11-next.1](https://github.com/tractr/traxion/compare/v2.0.11-next.0...v2.0.11-next.1) (2023-02-22)
+
+
+
+## [2.0.11-next.0](https://github.com/tractr/traxion/compare/v2.0.10...v2.0.11-next.0) (2023-02-22)
+
+
+### Features
+
+* clean authentication modules ([99b7db6](https://github.com/tractr/traxion/commit/99b7db69cc4f885ac885d147043003448895d66d))
+
+
+
## [2.0.13](https://github.com/tractr/traxion/compare/v2.0.12...v2.0.13) (2023-02-24)
diff --git a/libs/nestjs/database/package.json b/libs/nestjs/database/package.json
index cc116623a..675d24d4b 100644
--- a/libs/nestjs/database/package.json
+++ b/libs/nestjs/database/package.json
@@ -1,6 +1,6 @@
{
"name": "@trxn/nestjs-database",
- "version": "2.0.13",
+ "version": "2.1.0-next.1",
"description": "Database module for nestjs backend",
"repository": {
"type": "git",
diff --git a/libs/nestjs/database/src/services/database.service.ts b/libs/nestjs/database/src/services/database.service.ts
index ebe4a5cec..7c6e83203 100644
--- a/libs/nestjs/database/src/services/database.service.ts
+++ b/libs/nestjs/database/src/services/database.service.ts
@@ -8,9 +8,9 @@ import {
} from '@nestjs/common';
import { Prisma, PrismaClient } from '@prisma/client';
-import { PRISMA_MODULE_OPTIONS } from '../constants';
import { MysqlService } from './mysql.service';
import { PostgresqlService } from './postgresql.service';
+import { PRISMA_MODULE_OPTIONS } from '../constants';
export type PrismaClientOptions = Omit<
Prisma.PrismaClientOptions,
diff --git a/libs/nestjs/file-storage/CHANGELOG.md b/libs/nestjs/file-storage/CHANGELOG.md
index a5a35b30c..1684efb3e 100644
--- a/libs/nestjs/file-storage/CHANGELOG.md
+++ b/libs/nestjs/file-storage/CHANGELOG.md
@@ -2,6 +2,35 @@
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
+# [2.1.0-next.1](https://github.com/tractr/traxion/compare/v2.1.0-next.0...v2.1.0-next.1) (2023-02-27)
+
+
+
+# [2.1.0-next.0](https://github.com/tractr/traxion/compare/v2.0.13...v2.1.0-next.0) (2023-02-27)
+
+
+
+## [2.0.11-next.3](https://github.com/tractr/traxion/compare/v2.0.11-next.2...v2.0.11-next.3) (2023-02-22)
+
+
+
+## [2.0.11-next.2](https://github.com/tractr/traxion/compare/v2.0.11-next.1...v2.0.11-next.2) (2023-02-22)
+
+
+
+## [2.0.11-next.1](https://github.com/tractr/traxion/compare/v2.0.11-next.0...v2.0.11-next.1) (2023-02-22)
+
+
+
+## [2.0.11-next.0](https://github.com/tractr/traxion/compare/v2.0.10...v2.0.11-next.0) (2023-02-22)
+
+
+### Features
+
+* clean authentication modules ([99b7db6](https://github.com/tractr/traxion/commit/99b7db69cc4f885ac885d147043003448895d66d))
+
+
+
## [2.0.13](https://github.com/tractr/traxion/compare/v2.0.12...v2.0.13) (2023-02-24)
diff --git a/libs/nestjs/file-storage/package.json b/libs/nestjs/file-storage/package.json
index 1faf9b3fc..bb64b6169 100644
--- a/libs/nestjs/file-storage/package.json
+++ b/libs/nestjs/file-storage/package.json
@@ -1,6 +1,6 @@
{
"name": "@trxn/nestjs-file-storage",
- "version": "2.0.13",
+ "version": "2.1.0-next.1",
"repository": {
"type": "git",
"url": "https://github.com/tractr/traxion"
diff --git a/libs/nestjs/file-storage/src/lib/controllers/file-storage.controller.spec.ts b/libs/nestjs/file-storage/src/lib/controllers/file-storage.controller.spec.ts
index 5492d0b98..1fa6185f8 100644
--- a/libs/nestjs/file-storage/src/lib/controllers/file-storage.controller.spec.ts
+++ b/libs/nestjs/file-storage/src/lib/controllers/file-storage.controller.spec.ts
@@ -3,9 +3,9 @@
import { Test, TestingModule } from '@nestjs/testing';
import { mockDeep, MockProxy, mockReset } from 'jest-mock-extended';
+import { FileStorageController } from './file-storage.controller';
import { GetPresignedDownloadUrlQueryDto } from '../dtos';
import { FileStorageService } from '../services';
-import { FileStorageController } from './file-storage.controller';
describe('FileStorageController', () => {
let mockFileStorageService: MockProxy;
diff --git a/libs/nestjs/file-storage/src/lib/dtos/file-storage-configuration-private.dto.ts b/libs/nestjs/file-storage/src/lib/dtos/file-storage-configuration-private.dto.ts
index 060591785..959a11593 100644
--- a/libs/nestjs/file-storage/src/lib/dtos/file-storage-configuration-private.dto.ts
+++ b/libs/nestjs/file-storage/src/lib/dtos/file-storage-configuration-private.dto.ts
@@ -9,9 +9,9 @@ import {
} from 'class-validator';
import { ClientOptions as MinioClientOptions, Region } from 'minio';
-import { AwsRegions } from '../constants';
import { PresignedDownloadConfigurationDto } from './presigned-download-configuration.dto';
import { PresignedUploadConfigurationDto } from './presigned-upload-configuration';
+import { AwsRegions } from '../constants';
import { getDefaults } from '@trxn/common';
diff --git a/libs/nestjs/graphql/CHANGELOG.md b/libs/nestjs/graphql/CHANGELOG.md
index add563699..846e7eca6 100644
--- a/libs/nestjs/graphql/CHANGELOG.md
+++ b/libs/nestjs/graphql/CHANGELOG.md
@@ -2,6 +2,14 @@
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
+# [2.1.0-next.1](https://github.com/tractr/traxion/compare/v2.1.0-next.0...v2.1.0-next.1) (2023-02-27)
+
+
+
+# [2.1.0-next.0](https://github.com/tractr/traxion/compare/v2.0.13...v2.1.0-next.0) (2023-02-27)
+
+
+
## [2.0.13](https://github.com/tractr/traxion/compare/v2.0.12...v2.0.13) (2023-02-24)
diff --git a/libs/nestjs/graphql/package.json b/libs/nestjs/graphql/package.json
index 4fec1fe15..0d546a728 100644
--- a/libs/nestjs/graphql/package.json
+++ b/libs/nestjs/graphql/package.json
@@ -1,6 +1,6 @@
{
"name": "@trxn/nestjs-graphql",
- "version": "2.0.13",
+ "version": "2.1.0-next.1",
"description": "Nestjs graphql helper",
"repository": {
"type": "git",
diff --git a/libs/nestjs/mailer/CHANGELOG.md b/libs/nestjs/mailer/CHANGELOG.md
index 98e7ce967..1da2438a7 100644
--- a/libs/nestjs/mailer/CHANGELOG.md
+++ b/libs/nestjs/mailer/CHANGELOG.md
@@ -2,6 +2,41 @@
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
+# [2.1.0-next.1](https://github.com/tractr/traxion/compare/v2.1.0-next.0...v2.1.0-next.1) (2023-02-27)
+
+
+
+# [2.1.0-next.0](https://github.com/tractr/traxion/compare/v2.0.13...v2.1.0-next.0) (2023-02-27)
+
+
+
+## [2.0.11-next.3](https://github.com/tractr/traxion/compare/v2.0.11-next.2...v2.0.11-next.3) (2023-02-22)
+
+
+
+## [2.0.11-next.2](https://github.com/tractr/traxion/compare/v2.0.11-next.1...v2.0.11-next.2) (2023-02-22)
+
+
+
+## [2.0.11-next.1](https://github.com/tractr/traxion/compare/v2.0.11-next.0...v2.0.11-next.1) (2023-02-22)
+
+
+
+## [2.0.11-next.0](https://github.com/tractr/traxion/compare/v2.0.10...v2.0.11-next.0) (2023-02-22)
+
+
+### Bug Fixes
+
+* update mailer to use mailjet v6 ([2a4a060](https://github.com/tractr/traxion/commit/2a4a0607963235cbb859e8ff99794829f7eaaf58))
+* update mailer to use mailjet v6 ([7db4aaf](https://github.com/tractr/traxion/commit/7db4aaf835f96c33f9d0be4e2bff503c925fc138))
+
+
+### Features
+
+* clean authentication modules ([99b7db6](https://github.com/tractr/traxion/commit/99b7db69cc4f885ac885d147043003448895d66d))
+
+
+
## [2.0.13](https://github.com/tractr/traxion/compare/v2.0.12...v2.0.13) (2023-02-24)
diff --git a/libs/nestjs/mailer/README.md b/libs/nestjs/mailer/README.md
index 3331ca0f7..f4929ea3f 100644
--- a/libs/nestjs/mailer/README.md
+++ b/libs/nestjs/mailer/README.md
@@ -1,8 +1,117 @@
-# nestjs-mailer
+# MailerModule
-This library was generated with [Nx](https://nx.dev).
+This module provides a MailerService that can be used to send emails.
-## Running unit tests
+## Installation
-Run `nx test nestjs-mailer` to execute the unit tests via
-[Jest](https://jestjs.io).
+```bash
+npm i --save @trxn/nestjs-mailer @trxn/nestjs-mailjet
+```
+
+## Quick Start
+
+First configure the mailjet module, the documentation can be found [here](https://www.traxion.dev/docs/how-to/mailer/use-mailjet).
+
+Then, import the MailerModule in your root application module:
+
+```ts
+import { Module } from '@nestjs/common';
+import { MailjetModule as Mailjet } from '@trxn/nestjs-mailjet';
+import { MailerModule } from '@trxn/nestjs-mailer';
+
+@Module({
+ imports: [
+ Mailjet.register({
+ apiKey: 'YOUR_MAILER_API_KEY',
+ }),
+ ],
+})
+export class MailjetModule {}
+
+@Module({
+ imports: [
+ MailerModule.register({
+ imports: [MailjetModule],
+ production: process.env.NODE_ENV === 'production',
+ }),
+ ],
+})
+export class MailerModule {}
+
+@Module({
+ imports: [
+ MailerModule,
+ ],
+})
+export class AppModule {}
+```
+
+In the example above and in order to use the mailerModule in an efficient way you must separate your declaration into multiple submodules. The MailjetModule expose internally a `MAILER_CLIENT` provider that is directly used inside the `MailerModule`. You can use the `MailjetModule` or another module of you choice to be able to send email with `MailerModule`. The other traxion module that use the emails providers will inject a `MailerService` that comme from the `MailerModule`.
+
+Then to use the MailerService to send an email, inject it into your service or controller:
+
+```ts
+import { Controller, Get, Inject } from '@nestjs/common';
+import { MailerService } from '@trxn/nestjs-mailer';
+
+@Controller()
+export class AppController {
+ constructor(
+ @Inject(MailerService) private readonly mailerService: MailerService,
+ ) {}
+
+ @Get()
+ async sendEmail(): Promise {
+ const email = {
+ from: 'YOUR_EMAIL_ADDRESS',
+ to: 'RECIPIENT_EMAIL_ADDRESS',
+ subject: 'Test email',
+ text: 'This is a test email',
+ };
+ await this.mailerService.send(email);
+ }
+}
+```
+
+In the example above, the MailerService is injected into the AppController and used to send an email with a from address, to address, subject, and text content.
+
+## MailerModule Options
+
+The register() and registerAsync() methods accept an options object of type MailerModuleOptions.
+
+| Property | Type | Description |
+| --- | --- | --- |
+| `production` | `boolean` | (optional) Default to `false`, tell the module to really send the email when set to true |
+
+## MailerService Methods
+
+The MailjetService provides a single method for sending email:
+
+### send
+
+```ts
+send(params: SendEmailParams): Promise
+````
+
+Sends an email using the Mailjet API.
+
+| Property | Type | Description |
+| --- | --- | --- |
+| `params` | `SendEmailParams` | The email parameters. |
+
+The SendEmailParams interface has the following properties:
+
+```ts
+interface SendEmailParams {
+ from: string;
+ to: string | string[];
+ subject?: string;
+ html?: string;
+ text?: string;
+ context?: Record;
+}
+```
+
+## Conclusion
+
+The nestjs-mailer module provides a simple and convenient way to allow you to shadow your email provider behind a contractual interface. The other module from traxion will use the `MailerModule` and his `MailerService` to send email when needed.
diff --git a/libs/nestjs/mailer/package.json b/libs/nestjs/mailer/package.json
index e2fa5a040..7bf0e42a4 100644
--- a/libs/nestjs/mailer/package.json
+++ b/libs/nestjs/mailer/package.json
@@ -1,6 +1,6 @@
{
"name": "@trxn/nestjs-mailer",
- "version": "2.0.13",
+ "version": "2.1.0-next.1",
"repository": {
"type": "git",
"url": "https://github.com/tractr/traxion"
diff --git a/libs/nestjs/mailer/src/constants/index.ts b/libs/nestjs/mailer/src/constants/index.ts
new file mode 100644
index 000000000..6b12a0dfd
--- /dev/null
+++ b/libs/nestjs/mailer/src/constants/index.ts
@@ -0,0 +1 @@
+export * from './mailer.constants';
diff --git a/libs/nestjs/mailer/src/constants/mailer.constants.ts b/libs/nestjs/mailer/src/constants/mailer.constants.ts
new file mode 100644
index 000000000..864ce45b9
--- /dev/null
+++ b/libs/nestjs/mailer/src/constants/mailer.constants.ts
@@ -0,0 +1 @@
+export const MAILER_CLIENT = 'MAILER_CLIENT' as const;
diff --git a/libs/nestjs/mailer/src/index.ts b/libs/nestjs/mailer/src/index.ts
index 9c55c09ed..b6fa6db4c 100644
--- a/libs/nestjs/mailer/src/index.ts
+++ b/libs/nestjs/mailer/src/index.ts
@@ -1,4 +1,4 @@
-export * from './lib/configs';
-export * from './lib/interfaces';
-export * from './lib/services';
-export * from './lib/mailer.module';
+export * from './constants';
+export * from './interfaces';
+export * from './services';
+export * from './mailer.module';
diff --git a/libs/nestjs/mailer/src/interfaces/index.ts b/libs/nestjs/mailer/src/interfaces/index.ts
new file mode 100644
index 000000000..ef82ca40a
--- /dev/null
+++ b/libs/nestjs/mailer/src/interfaces/index.ts
@@ -0,0 +1,2 @@
+export * from './mailer-client.interface';
+export * from './mailer-module-options.interface';
diff --git a/libs/nestjs/mailer/src/interfaces/mailer-client.interface.ts b/libs/nestjs/mailer/src/interfaces/mailer-client.interface.ts
new file mode 100644
index 000000000..9c0a8b3f9
--- /dev/null
+++ b/libs/nestjs/mailer/src/interfaces/mailer-client.interface.ts
@@ -0,0 +1,12 @@
+export interface SendEmailParams {
+ from: string;
+ to: string | string[];
+ subject?: string;
+ context?: Record;
+ text?: string;
+ html?: string;
+}
+
+export interface MailerClient {
+ send(params: SendEmailParams): Promise;
+}
diff --git a/libs/nestjs/mailer/src/interfaces/mailer-module-options.interface.ts b/libs/nestjs/mailer/src/interfaces/mailer-module-options.interface.ts
new file mode 100644
index 000000000..9c231e701
--- /dev/null
+++ b/libs/nestjs/mailer/src/interfaces/mailer-module-options.interface.ts
@@ -0,0 +1,3 @@
+export interface MailerModuleOptions {
+ production?: boolean;
+}
diff --git a/libs/nestjs/mailer/src/lib/cli/index.ts b/libs/nestjs/mailer/src/lib/cli/index.ts
deleted file mode 100644
index 96eae1a78..000000000
--- a/libs/nestjs/mailer/src/lib/cli/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from './mailer.cli';
diff --git a/libs/nestjs/mailer/src/lib/cli/mailer.cli.ts b/libs/nestjs/mailer/src/lib/cli/mailer.cli.ts
deleted file mode 100644
index e43cd6dfb..000000000
--- a/libs/nestjs/mailer/src/lib/cli/mailer.cli.ts
+++ /dev/null
@@ -1,49 +0,0 @@
-import { Command, Console } from 'nestjs-console';
-import * as mailjet from 'node-mailjet';
-
-import { MailerService } from '../services';
-
-@Console({
- command: 'mailer',
-})
-export class MailerCliService {
- constructor(private readonly mailerService: MailerService) {}
-
- @Command({
- command: 'send ',
- description: 'Send a mail to recipient',
- })
- public async send(email: string): Promise {
- const params: mailjet.Email.SendParams = this.getSendEmailParams(email);
- try {
- const response = await this.mailerService.send(params);
- console.info(response);
- } catch (e) {
- console.warn(e);
- }
- }
-
- private getSendEmailParams(email: string): mailjet.Email.SendParams {
- return {
- Messages: [
- {
- From: {
- Email: 'dt@trxn.net',
- Name: 'Tractr',
- },
- To: [
- {
- Email: email,
- Name: 'Jean Claude',
- },
- ],
- Subject: 'This is an email to test Node Mailer Module',
- TextPart:
- 'Dear Jean Claude, welcome to Mailjet! May the delivery force be with you!',
- HTMLPart:
- 'Dear Jean Claude, welcome to Mailjet!
May the delivery force be with you!',
- },
- ],
- };
- }
-}
diff --git a/libs/nestjs/mailer/src/lib/configs/index.ts b/libs/nestjs/mailer/src/lib/configs/index.ts
deleted file mode 100644
index 573ba2276..000000000
--- a/libs/nestjs/mailer/src/lib/configs/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from './mailer.config';
diff --git a/libs/nestjs/mailer/src/lib/constants/index.ts b/libs/nestjs/mailer/src/lib/constants/index.ts
deleted file mode 100644
index 7f177f34b..000000000
--- a/libs/nestjs/mailer/src/lib/constants/index.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-export * from './mailer.constants';
-export * from './reset-password-send-email.constant';
diff --git a/libs/nestjs/mailer/src/lib/constants/mailer.constants.ts b/libs/nestjs/mailer/src/lib/constants/mailer.constants.ts
deleted file mode 100644
index 2cca35759..000000000
--- a/libs/nestjs/mailer/src/lib/constants/mailer.constants.ts
+++ /dev/null
@@ -1 +0,0 @@
-export const MAILER_MODULE_OPTIONS = 'MAILER_MODULE_OPTIONS';
diff --git a/libs/nestjs/mailer/src/lib/helpers/are-we-testing.ts b/libs/nestjs/mailer/src/lib/helpers/are-we-testing.ts
deleted file mode 100644
index 1f8f3c546..000000000
--- a/libs/nestjs/mailer/src/lib/helpers/are-we-testing.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-export function areWeTestingWithJest() {
- return process.env.JEST_WORKER_ID !== undefined;
-}
diff --git a/libs/nestjs/mailer/src/lib/helpers/index.ts b/libs/nestjs/mailer/src/lib/helpers/index.ts
deleted file mode 100644
index 5dadbe5a7..000000000
--- a/libs/nestjs/mailer/src/lib/helpers/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from './are-we-testing';
diff --git a/libs/nestjs/mailer/src/lib/interfaces/index.ts b/libs/nestjs/mailer/src/lib/interfaces/index.ts
deleted file mode 100644
index 1f3cd7ea4..000000000
--- a/libs/nestjs/mailer/src/lib/interfaces/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from './mailer.interface';
diff --git a/libs/nestjs/mailer/src/lib/interfaces/mailer.interface.ts b/libs/nestjs/mailer/src/lib/interfaces/mailer.interface.ts
deleted file mode 100644
index af2ffaa38..000000000
--- a/libs/nestjs/mailer/src/lib/interfaces/mailer.interface.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-export type MailerOptions = {
- publicApiKey: string;
- privateApiKey: string;
-};
-
-export type MailerPublicOptions = MailerOptions;
diff --git a/libs/nestjs/mailer/src/lib/mailer.module.ts b/libs/nestjs/mailer/src/lib/mailer.module.ts
deleted file mode 100644
index 38beb72b3..000000000
--- a/libs/nestjs/mailer/src/lib/mailer.module.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import { HttpModule } from '@nestjs/axios';
-import { Module } from '@nestjs/common';
-
-import { MailerCliService } from './cli';
-import { MAILER_MODULE_OPTIONS } from './constants';
-import { MailerOptions, MailerPublicOptions } from './interfaces';
-import { MailerService } from './services';
-import { ResetPasswordSendEmailService } from './services/reset-password-send-email.service';
-
-import { ModuleOptionsFactory } from '@trxn/nestjs-core';
-
-@Module({
- imports: [HttpModule],
- providers: [MailerService, MailerCliService, ResetPasswordSendEmailService],
- exports: [MailerService, ResetPasswordSendEmailService],
-})
-export class MailerModule extends ModuleOptionsFactory<
- MailerOptions,
- MailerPublicOptions
->(MAILER_MODULE_OPTIONS) {}
diff --git a/libs/nestjs/mailer/src/lib/services/index.ts b/libs/nestjs/mailer/src/lib/services/index.ts
deleted file mode 100644
index 786ee7aa5..000000000
--- a/libs/nestjs/mailer/src/lib/services/index.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-export * from './mailer.service';
-export * from './reset-password-send-email.service';
diff --git a/libs/nestjs/mailer/src/lib/services/mailer.service.ts b/libs/nestjs/mailer/src/lib/services/mailer.service.ts
deleted file mode 100644
index 48521ee34..000000000
--- a/libs/nestjs/mailer/src/lib/services/mailer.service.ts
+++ /dev/null
@@ -1,41 +0,0 @@
-import { Inject, Injectable } from '@nestjs/common';
-import * as mailjet from 'node-mailjet';
-
-import { MAILJET_API_VERSION } from '../configs';
-import { MAILER_MODULE_OPTIONS } from '../constants';
-import { areWeTestingWithJest } from '../helpers';
-import { MailerOptions } from '../interfaces';
-
-import { isProduction } from '@trxn/nestjs-core';
-
-@Injectable()
-export class MailerService {
- mailjetClient!: mailjet.Email.Client;
-
- constructor(
- @Inject(MAILER_MODULE_OPTIONS)
- private readonly mailerOptions: MailerOptions,
- ) {
- this.connectToMailjetApi();
- }
-
- public async send(
- params: mailjet.Email.SendParams,
- ): Promise {
- if (areWeTestingWithJest()) return null;
-
- return this.mailjetClient
- .post('send', { version: MAILJET_API_VERSION })
- .request({
- SandboxMode: !isProduction(),
- ...params,
- });
- }
-
- private connectToMailjetApi(): void {
- this.mailjetClient = mailjet.connect(
- this.mailerOptions.publicApiKey,
- this.mailerOptions.privateApiKey,
- );
- }
-}
diff --git a/libs/nestjs/mailer/src/lib/services/reset-password-send-email.service.ts b/libs/nestjs/mailer/src/lib/services/reset-password-send-email.service.ts
deleted file mode 100644
index b7b2a2fbd..000000000
--- a/libs/nestjs/mailer/src/lib/services/reset-password-send-email.service.ts
+++ /dev/null
@@ -1,99 +0,0 @@
-import { Injectable } from '@nestjs/common';
-import * as mailjet from 'node-mailjet';
-
-import { DEFAULT_RESET_HTML, DEFAULT_UPDATED_HTML } from '../constants';
-import { MailerService } from './mailer.service';
-
-@Injectable()
-export class ResetPasswordSendEmailService {
- constructor(private readonly mailerService: MailerService) {}
-
- sendRequestResetPasswordEmailFactory({
- from,
- templateId,
- subject,
- variables,
- }: {
- from: string;
- templateId?: number;
- subject?: string;
- variables?: Record;
- }): (
- link: string,
- resetCode: string,
- user: Record,
- ) => Promise | void {
- return async (
- link: string,
- resetCode: string,
- user: Record,
- ) => {
- if (!from) {
- throw new Error(
- 'send request reset password email: from option is required',
- );
- }
-
- const message: mailjet.Email.SendParamsMessage = {
- From: {
- Email: from,
- },
- To: [{ Email: user.email as string }],
- TemplateLanguage: true,
- Subject: subject,
- ...(templateId
- ? { TemplateID: templateId }
- : { HTMLPart: DEFAULT_RESET_HTML }),
- Variables: {
- link,
- email: user.email,
- ...(variables ?? {}),
- },
- };
-
- await this.mailerService.send({
- Messages: [message],
- });
- };
- }
-
- sendUpdatedPasswordEmailFactory({
- from,
- templateId,
- subject,
- variables,
- }: {
- from: string;
- templateId?: number;
- subject?: string;
- variables?: Record;
- }): (user: Record) => Promise | void {
- return async (user: Record) => {
- if (!from) {
- throw new Error(
- 'send request reset password email: from option is required',
- );
- }
-
- const message: mailjet.Email.SendParamsMessage = {
- From: {
- Email: from,
- },
- To: [{ Email: user.email as string }],
- TemplateLanguage: true,
- Subject: subject,
- ...(templateId
- ? { TemplateID: templateId }
- : { HTMLPart: DEFAULT_UPDATED_HTML }),
- Variables: {
- email: user.email,
- ...(variables ?? {}),
- },
- };
-
- await this.mailerService.send({
- Messages: [message],
- });
- };
- }
-}
diff --git a/libs/nestjs/mailer/src/mailer.module-definition.ts b/libs/nestjs/mailer/src/mailer.module-definition.ts
new file mode 100644
index 000000000..4b099d5fd
--- /dev/null
+++ b/libs/nestjs/mailer/src/mailer.module-definition.ts
@@ -0,0 +1,34 @@
+import { ConfigurableModuleBuilder } from '@nestjs/common';
+
+import { MAILER_CLIENT } from './constants';
+import { MailerClient, MailerModuleOptions } from './interfaces';
+
+import {
+ addImportsAndProvidersExtra,
+ addProviderWithInjectionTokenExtra,
+ ImportsExtra,
+ ProvidersExtra,
+ ProviderWithInjectionToken,
+} from '@trxn/nestjs-core';
+
+export const {
+ ConfigurableModuleClass,
+ MODULE_OPTIONS_TOKEN,
+ ASYNC_OPTIONS_TYPE,
+ OPTIONS_TYPE,
+} = new ConfigurableModuleBuilder()
+ .setExtras<
+ ImportsExtra &
+ ProvidersExtra & {
+ MailerClient?: ProviderWithInjectionToken<
+ typeof MAILER_CLIENT,
+ MailerClient
+ >;
+ }
+ >(
+ { imports: [], providers: [] },
+ addImportsAndProvidersExtra((definition, { MailerClient: Client }) =>
+ addProviderWithInjectionTokenExtra(definition, MAILER_CLIENT, Client),
+ ),
+ )
+ .build();
diff --git a/libs/nestjs/mailer/src/mailer.module.ts b/libs/nestjs/mailer/src/mailer.module.ts
new file mode 100644
index 000000000..049421566
--- /dev/null
+++ b/libs/nestjs/mailer/src/mailer.module.ts
@@ -0,0 +1,13 @@
+import { Module } from '@nestjs/common';
+
+import { ConfigurableModuleClass } from './mailer.module-definition';
+import { MailerService } from './services';
+
+import { LoggerModule } from '@trxn/nestjs-core';
+
+@Module({
+ imports: [LoggerModule],
+ providers: [MailerService],
+ exports: [MailerService],
+})
+export class MailerModule extends ConfigurableModuleClass {}
diff --git a/libs/nestjs/mailer/src/services/index.ts b/libs/nestjs/mailer/src/services/index.ts
new file mode 100644
index 000000000..13137e36f
--- /dev/null
+++ b/libs/nestjs/mailer/src/services/index.ts
@@ -0,0 +1 @@
+export * from './mailer.service';
diff --git a/libs/nestjs/mailer/src/services/mailer.service.ts b/libs/nestjs/mailer/src/services/mailer.service.ts
new file mode 100644
index 000000000..fd7d6a4a5
--- /dev/null
+++ b/libs/nestjs/mailer/src/services/mailer.service.ts
@@ -0,0 +1,40 @@
+import { Inject, Injectable, Logger } from '@nestjs/common';
+
+import { MAILER_CLIENT } from '../constants';
+import {
+ MailerClient,
+ MailerModuleOptions,
+ SendEmailParams,
+} from '../interfaces';
+import { MODULE_OPTIONS_TOKEN } from '../mailer.module-definition';
+
+import { LoggerService } from '@trxn/nestjs-core';
+
+@Injectable()
+export class MailerService {
+ constructor(
+ @Inject(MODULE_OPTIONS_TOKEN)
+ private readonly mailerOptions: MailerModuleOptions,
+
+ @Inject(MAILER_CLIENT)
+ private readonly mailerClient: MailerClient,
+
+ @Inject(Logger)
+ private readonly logger: LoggerService,
+ ) {
+ this.logger.setContext(MailerService.name);
+ }
+
+ public async send(params: SendEmailParams): Promise {
+ this.logger.debug('Sending email: ', params);
+
+ if (!this.mailerOptions.production) {
+ this.logger.debug(
+ 'Server is in development mode, email has not been send via the MailerClient',
+ );
+ return null;
+ }
+
+ return this.mailerClient.send(params);
+ }
+}
diff --git a/libs/nestjs/mailjet/.babelrc b/libs/nestjs/mailjet/.babelrc
new file mode 100644
index 000000000..e24a5465f
--- /dev/null
+++ b/libs/nestjs/mailjet/.babelrc
@@ -0,0 +1,10 @@
+{
+ "presets": [
+ [
+ "@nrwl/web/babel",
+ {
+ "useBuiltIns": "usage"
+ }
+ ]
+ ]
+}
diff --git a/libs/nestjs/mailjet/.eslintrc.json b/libs/nestjs/mailjet/.eslintrc.json
new file mode 100644
index 000000000..3456be9b9
--- /dev/null
+++ b/libs/nestjs/mailjet/.eslintrc.json
@@ -0,0 +1,18 @@
+{
+ "extends": ["../../../.eslintrc.json"],
+ "ignorePatterns": ["!**/*"],
+ "overrides": [
+ {
+ "files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
+ "rules": {}
+ },
+ {
+ "files": ["*.ts", "*.tsx"],
+ "rules": {}
+ },
+ {
+ "files": ["*.js", "*.jsx"],
+ "rules": {}
+ }
+ ]
+}
diff --git a/libs/nestjs/mailjet/CHANGELOG.md b/libs/nestjs/mailjet/CHANGELOG.md
new file mode 100644
index 000000000..4e491c6f0
--- /dev/null
+++ b/libs/nestjs/mailjet/CHANGELOG.md
@@ -0,0 +1,91 @@
+# Changelog
+
+This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
+
+# [2.1.0-next.1](https://github.com/tractr/traxion/compare/v2.1.0-next.0...v2.1.0-next.1) (2023-02-27)
+
+
+
+# [2.1.0-next.0](https://github.com/tractr/traxion/compare/v2.0.13...v2.1.0-next.0) (2023-02-27)
+
+
+
+## [2.0.11-next.3](https://github.com/tractr/traxion/compare/v2.0.11-next.2...v2.0.11-next.3) (2023-02-22)
+
+
+### Bug Fixes
+
+* update MAILER_CLIENT providers ([7dbf6e3](https://github.com/tractr/traxion/commit/7dbf6e33654718e1d47b98165b67dea7d5063ac8))
+
+
+
+## [2.0.11-next.2](https://github.com/tractr/traxion/compare/v2.0.11-next.1...v2.0.11-next.2) (2023-02-22)
+
+
+### Bug Fixes
+
+* add casl public permissions and MAILER_CLIENT token ([46f4b06](https://github.com/tractr/traxion/commit/46f4b06da9d46a79c36bde365cd817b46031e24f))
+
+
+
+## [2.0.11-next.1](https://github.com/tractr/traxion/compare/v2.0.11-next.0...v2.0.11-next.1) (2023-02-22)
+
+
+### Bug Fixes
+
+* remove [@tractr](https://github.com/tractr) and replace it by [@trxn](https://github.com/trxn) ([129058f](https://github.com/tractr/traxion/commit/129058fee9f88c34ac4f124f9d1d54470939a0e7))
+
+
+
+## [2.0.11-next.0](https://github.com/tractr/traxion/compare/v2.0.10...v2.0.11-next.0) (2023-02-22)
+
+
+### Bug Fixes
+
+* update mailer to use mailjet v6 ([2a4a060](https://github.com/tractr/traxion/commit/2a4a0607963235cbb859e8ff99794829f7eaaf58))
+
+
+### Features
+
+* clean authentication modules ([99b7db6](https://github.com/tractr/traxion/commit/99b7db69cc4f885ac885d147043003448895d66d))
+
+
+
+## [2.0.11-next.3](https://github.com/tractr/traxion/compare/v2.0.11-next.2...v2.0.11-next.3) (2023-02-22)
+
+
+### Bug Fixes
+
+* update MAILER_CLIENT providers ([7dbf6e3](https://github.com/tractr/traxion/commit/7dbf6e33654718e1d47b98165b67dea7d5063ac8))
+
+
+
+## [2.0.11-next.2](https://github.com/tractr/traxion/compare/v2.0.11-next.1...v2.0.11-next.2) (2023-02-22)
+
+
+### Bug Fixes
+
+* add casl public permissions and MAILER_CLIENT token ([46f4b06](https://github.com/tractr/traxion/commit/46f4b06da9d46a79c36bde365cd817b46031e24f))
+
+
+
+## [2.0.11-next.1](https://github.com/tractr/traxion/compare/v2.0.11-next.0...v2.0.11-next.1) (2023-02-22)
+
+
+### Bug Fixes
+
+* remove [@tractr](https://github.com/tractr) and replace it by [@trxn](https://github.com/trxn) ([129058f](https://github.com/tractr/traxion/commit/129058fee9f88c34ac4f124f9d1d54470939a0e7))
+
+
+
+## [2.0.11-next.0](https://github.com/tractr/traxion/compare/v2.0.10...v2.0.11-next.0) (2023-02-22)
+
+
+### Bug Fixes
+
+* update mailer to use mailjet v6 ([2a4a060](https://github.com/tractr/traxion/commit/2a4a0607963235cbb859e8ff99794829f7eaaf58))
+
+
+### Features
+
+* clean authentication modules ([99b7db6](https://github.com/tractr/traxion/commit/99b7db69cc4f885ac885d147043003448895d66d))
diff --git a/libs/nestjs/mailjet/README.md b/libs/nestjs/mailjet/README.md
new file mode 100644
index 000000000..c6aff845e
--- /dev/null
+++ b/libs/nestjs/mailjet/README.md
@@ -0,0 +1,143 @@
+# Mailjet Module
+
+The nestjs-mailjet module provides a simple wrapper for the Mailjet API,
+allowing NestJS applications to easily send transactional emails using the
+Mailjet email delivery service.
+
+## Installation
+
+You can install the nestjs-mailjet module using npm:
+
+```bash
+npm install --save @trxn/nestjs-mailjet
+````
+
+## Getting Started
+
+To use the nestjs-mailjet module, you first need to import it into your NestJS
+application. You can do this by adding the MailjetModule to your app's imports array:
+
+```ts
+import { MailjetModule } from '@trxn/nestjs-mailjet';
+
+@Module({
+ imports: [
+ MailjetModule.forRoot({
+ apiKey: 'your_api_key',
+ apiSecret: 'your_api_secret',
+ }),
+ ],
+})
+export class AppModule {}
+```
+
+The forRoot method takes an options object with the following properties:
+
+- `apiKey`: The Mailjet API key.
+- `apiSecret`: The Mailjet API secret.
+- `sandboxMode` (optional): A boolean value indicating whether to enable sandbox mode. Default is `false`.
+
+This module options extends the mailjet `ClientParams` options. You can find more [here](https://www.npmjs.com/package/node-mailjet).
+
+## Injecting the MailjetService
+
+Once the MailjetModule is imported, you can inject the MailjetService into your controllers or services:
+
+```ts
+import { Injectable } from '@nestjs/common';
+import { MailjetService } from '@trxn/nestjs-mailjet';
+
+@Injectable()
+export class EmailsService {
+ constructor(private readonly mailjetService: MailjetService) {}
+
+ async sendEmail(data: any) {
+ const { from, to, subject, html, text } = data;
+
+ await this.mailjetService.send({
+ from,
+ to,
+ subject,
+ html,
+ text,
+ });
+ }
+}
+```
+
+The MailjetModule expose the same service with an alias token: 'MAILER_CLIENT' from the `@trxn/nestjs-mailer` package. So you can import this service like this too:
+
+```ts
+import { Injectable } from '@nestjs/common';
+import { MAILER_CLIENT } from '@trxn/nestjs-mailer';
+import { MailjetService } from '@trxn/nestjs-mailjet';
+
+@Injectable()
+export class EmailsService {
+ constructor(@Inject(MAILER_CLIENT) private readonly mailjetService: MailjetService) {}
+
+ async sendEmail(data: any) {
+ const { from, to, subject, html, text } = data;
+
+ await this.mailjetService.send({
+ from,
+ to,
+ subject,
+ html,
+ text,
+ });
+ }
+}
+```
+
+## Using Templates
+
+You can also use email templates with the MailjetService by passing a templateId and context:
+
+```ts
+await this.mailjetService.send({
+ from,
+ to,
+ subject,
+ context: {
+ templateId: 12345,
+ name: 'John Doe',
+ orderNumber: 12345,
+ },
+});
+```
+
+## API
+
+The MailjetService provides a single method for sending email:
+
+### send
+
+```ts
+send(params: SendEmailParams): Promise
+````
+
+Sends an email using the Mailjet API.
+
+| Property | Type | Description |
+| --- | --- | --- |
+| `params` | `SendEmailParams` | The email parameters. |
+
+The SendEmailParams interface has the following properties:
+
+```ts
+interface SendEmailParams {
+ from: string;
+ to: string | string[];
+ subject?: string;
+ html?: string;
+ text?: string;
+ context?: Record & {
+ templateId?: number;
+ };
+}
+```
+
+## Conclusion
+
+The nestjs-mailjet module provides a simple and convenient way to send transactional emails via the Mailjet API in a NestJS application. By using this module, you can easily integrate email sending functionality into your app and focus on building other important features.
diff --git a/libs/nestjs/mailjet/jest.config.ts b/libs/nestjs/mailjet/jest.config.ts
new file mode 100644
index 000000000..88cfb78a4
--- /dev/null
+++ b/libs/nestjs/mailjet/jest.config.ts
@@ -0,0 +1,16 @@
+/* eslint-disable */
+export default {
+ displayName: 'nestjs-mailjet',
+ preset: '../../../jest.preset.js',
+ globals: {
+ 'ts-jest': {
+ tsconfig: '/tsconfig.spec.json',
+ },
+ },
+ testEnvironment: 'node',
+ transform: {
+ '^.+\\.[tj]s$': 'ts-jest',
+ },
+ moduleFileExtensions: ['ts', 'js', 'html'],
+ coverageDirectory: '../../../coverage/libs/nestjs/mailjet',
+};
diff --git a/libs/nestjs/mailjet/package.json b/libs/nestjs/mailjet/package.json
new file mode 100644
index 000000000..b8934c22e
--- /dev/null
+++ b/libs/nestjs/mailjet/package.json
@@ -0,0 +1,13 @@
+{
+ "name": "@trxn/nestjs-mailjet",
+ "version": "2.1.0-next.1",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/tractr/traxion"
+ },
+ "type": "commonjs",
+ "publishConfig": {
+ "access": "public",
+ "registry": "https://registry.npmjs.org/"
+ }
+}
diff --git a/libs/nestjs/mailjet/project.json b/libs/nestjs/mailjet/project.json
new file mode 100644
index 000000000..30b262426
--- /dev/null
+++ b/libs/nestjs/mailjet/project.json
@@ -0,0 +1,47 @@
+{
+ "$schema": "../../../node_modules/nx/schemas/project-schema.json",
+ "name": "nestjs-mailjet",
+ "projectType": "library",
+ "sourceRoot": "libs/nestjs/mailjet/src",
+ "tags": [],
+ "targets": {
+ "build": {
+ "executor": "@nrwl/js:tsc",
+ "options": {
+ "assets": ["libs/nestjs/mailjet/*.md"],
+ "main": "libs/nestjs/mailjet/src/index.ts",
+ "outputPath": "dist/libs/nestjs/mailjet",
+ "packageJson": "libs/nestjs/mailjet/package.json",
+ "tsConfig": "libs/nestjs/mailjet/tsconfig.lib.json"
+ },
+ "outputs": ["{options.outputPath}"]
+ },
+ "lint": {
+ "executor": "@nrwl/linter:eslint",
+ "options": {
+ "lintFilePatterns": ["libs/nestjs/mailjet/**/*.ts"]
+ },
+ "outputs": ["{options.outputFile}"]
+ },
+ "publish": {
+ "executor": "ngx-deploy-npm:deploy",
+ "options": {
+ "access": "public"
+ }
+ },
+ "test": {
+ "executor": "@nrwl/jest:jest",
+ "options": {
+ "jestConfig": "libs/nestjs/mailjet/jest.config.ts",
+ "passWithNoTests": true
+ },
+ "outputs": ["coverage/libs/nestjs/mailjet"]
+ },
+ "update-peer-dependencies": {
+ "executor": "./dist/libs/schematics:update-peer-dependencies",
+ "options": {
+ "packageJsonPath": "{workspaceRoot}/dist/libs/nestjs/mailjet/package.json"
+ }
+ }
+ }
+}
diff --git a/libs/nestjs/mailjet/src/configs/index.ts b/libs/nestjs/mailjet/src/configs/index.ts
new file mode 100644
index 000000000..da717aabd
--- /dev/null
+++ b/libs/nestjs/mailjet/src/configs/index.ts
@@ -0,0 +1 @@
+export * from './mailjet.config';
diff --git a/libs/nestjs/mailer/src/lib/configs/mailer.config.ts b/libs/nestjs/mailjet/src/configs/mailjet.config.ts
similarity index 100%
rename from libs/nestjs/mailer/src/lib/configs/mailer.config.ts
rename to libs/nestjs/mailjet/src/configs/mailjet.config.ts
diff --git a/libs/nestjs/mailjet/src/index.ts b/libs/nestjs/mailjet/src/index.ts
new file mode 100644
index 000000000..1efd5e4aa
--- /dev/null
+++ b/libs/nestjs/mailjet/src/index.ts
@@ -0,0 +1,5 @@
+export * from './configs';
+export * from './interfaces';
+export * from './services';
+export * from './mailjet.module-definition';
+export * from './mailjet.module';
diff --git a/libs/nestjs/mailjet/src/interfaces/index.ts b/libs/nestjs/mailjet/src/interfaces/index.ts
new file mode 100644
index 000000000..40f349fc4
--- /dev/null
+++ b/libs/nestjs/mailjet/src/interfaces/index.ts
@@ -0,0 +1 @@
+export * from './mailjet.interface';
diff --git a/libs/nestjs/mailjet/src/interfaces/mailjet.interface.ts b/libs/nestjs/mailjet/src/interfaces/mailjet.interface.ts
new file mode 100644
index 000000000..8f23bba6f
--- /dev/null
+++ b/libs/nestjs/mailjet/src/interfaces/mailjet.interface.ts
@@ -0,0 +1,5 @@
+import { ClientParams } from 'node-mailjet/declarations/client/Client';
+
+export type MailjetModuleOptions = ClientParams & {
+ sandboxMode?: boolean;
+};
diff --git a/libs/nestjs/mailjet/src/mailjet.module-definition.ts b/libs/nestjs/mailjet/src/mailjet.module-definition.ts
new file mode 100644
index 000000000..5dbb700e6
--- /dev/null
+++ b/libs/nestjs/mailjet/src/mailjet.module-definition.ts
@@ -0,0 +1,10 @@
+import { ConfigurableModuleBuilder } from '@nestjs/common';
+
+import { MailjetModuleOptions } from './interfaces';
+
+export const {
+ ConfigurableModuleClass,
+ MODULE_OPTIONS_TOKEN,
+ ASYNC_OPTIONS_TYPE,
+ OPTIONS_TYPE,
+} = new ConfigurableModuleBuilder().build();
diff --git a/libs/nestjs/mailjet/src/mailjet.module.ts b/libs/nestjs/mailjet/src/mailjet.module.ts
new file mode 100644
index 000000000..a8f1462d4
--- /dev/null
+++ b/libs/nestjs/mailjet/src/mailjet.module.ts
@@ -0,0 +1,16 @@
+import { Module } from '@nestjs/common';
+
+import { ConfigurableModuleClass } from './mailjet.module-definition';
+import { MailjetClient, MailjetService } from './services';
+
+import { MAILER_CLIENT } from '@trxn/nestjs-mailer';
+
+@Module({
+ providers: [
+ MailjetClient,
+ MailjetService,
+ { provide: MAILER_CLIENT, useExisting: MailjetService },
+ ],
+ exports: [MailjetClient, MailjetService, MAILER_CLIENT],
+})
+export class MailjetModule extends ConfigurableModuleClass {}
diff --git a/libs/nestjs/mailjet/src/services/index.ts b/libs/nestjs/mailjet/src/services/index.ts
new file mode 100644
index 000000000..69389282e
--- /dev/null
+++ b/libs/nestjs/mailjet/src/services/index.ts
@@ -0,0 +1,2 @@
+export * from './mailjet-client.service';
+export * from './mailjet.service';
diff --git a/libs/nestjs/mailjet/src/services/mailjet-client.service.ts b/libs/nestjs/mailjet/src/services/mailjet-client.service.ts
new file mode 100644
index 000000000..c68bc460a
--- /dev/null
+++ b/libs/nestjs/mailjet/src/services/mailjet-client.service.ts
@@ -0,0 +1,19 @@
+import { Inject, Injectable } from '@nestjs/common';
+import { Client, Request } from 'node-mailjet';
+import { RequestConstructorConfig } from 'node-mailjet/declarations/request/Request';
+
+import { MailjetModuleOptions } from '../interfaces';
+import { MODULE_OPTIONS_TOKEN } from '../mailjet.module-definition';
+
+@Injectable()
+export class MailjetClient extends Client {
+ sandboxMode: boolean;
+
+ constructor(
+ @Inject(MODULE_OPTIONS_TOKEN)
+ mailerOptions: MailjetModuleOptions,
+ ) {
+ super(mailerOptions);
+ this.sandboxMode = mailerOptions.sandboxMode ?? false;
+ }
+}
diff --git a/libs/nestjs/mailjet/src/services/mailjet.service.ts b/libs/nestjs/mailjet/src/services/mailjet.service.ts
new file mode 100644
index 000000000..035b04ccf
--- /dev/null
+++ b/libs/nestjs/mailjet/src/services/mailjet.service.ts
@@ -0,0 +1,45 @@
+import { Injectable } from '@nestjs/common';
+import { SendEmailV3_1 as SendEmailMailjet } from 'node-mailjet';
+
+import { MailjetClient } from './mailjet-client.service';
+import { MAILJET_API_VERSION } from '../configs';
+
+import { MailerClient, SendEmailParams } from '@trxn/nestjs-mailer';
+
+@Injectable()
+export class MailjetService implements MailerClient {
+ constructor(protected mailjetClient: MailjetClient) {}
+
+ public async send({
+ from,
+ to,
+ context = {},
+ html,
+ subject,
+ text,
+ }: SendEmailParams) {
+ const { templateId, ...variables } = context;
+
+ const message: SendEmailMailjet.Message = {
+ From: {
+ Email: from,
+ },
+ To: (Array.isArray(to) ? to : [to]).map((email) => ({ Email: email })),
+ TemplateLanguage: true,
+ Subject: subject,
+ ...(templateId
+ ? { TemplateID: templateId as number }
+ : { HTMLPart: html, TextPart: text }),
+ Variables: variables,
+ };
+
+ const data: SendEmailMailjet.Body = {
+ Messages: [message],
+ SandboxMode: this.mailjetClient.sandboxMode,
+ };
+
+ return this.mailjetClient
+ .post('send', { version: MAILJET_API_VERSION })
+ .request(data);
+ }
+}
diff --git a/libs/nestjs/mailjet/tsconfig.json b/libs/nestjs/mailjet/tsconfig.json
new file mode 100644
index 000000000..a3ee1b600
--- /dev/null
+++ b/libs/nestjs/mailjet/tsconfig.json
@@ -0,0 +1,16 @@
+{
+ "compilerOptions": {
+ "module": "commonjs"
+ },
+ "extends": "../../../tsconfig.base.json",
+ "files": [],
+ "include": [],
+ "references": [
+ {
+ "path": "./tsconfig.lib.json"
+ },
+ {
+ "path": "./tsconfig.spec.json"
+ }
+ ]
+}
diff --git a/libs/nestjs/mailjet/tsconfig.lib.json b/libs/nestjs/mailjet/tsconfig.lib.json
new file mode 100644
index 000000000..d4c178082
--- /dev/null
+++ b/libs/nestjs/mailjet/tsconfig.lib.json
@@ -0,0 +1,11 @@
+{
+ "compilerOptions": {
+ "declaration": true,
+ "outDir": "../../../dist/out-tsc",
+ "target": "es6",
+ "types": ["node"]
+ },
+ "exclude": ["jest.config.ts", "**/*.spec.ts", "**/*.test.ts"],
+ "extends": "./tsconfig.json",
+ "include": ["**/*.ts"]
+}
diff --git a/libs/nestjs/mailjet/tsconfig.spec.json b/libs/nestjs/mailjet/tsconfig.spec.json
new file mode 100644
index 000000000..2239fc199
--- /dev/null
+++ b/libs/nestjs/mailjet/tsconfig.spec.json
@@ -0,0 +1,9 @@
+{
+ "compilerOptions": {
+ "module": "commonjs",
+ "outDir": "../../../dist/out-tsc",
+ "types": ["jest", "node"]
+ },
+ "extends": "./tsconfig.json",
+ "include": ["jest.config.ts", "**/*.test.ts", "**/*.spec.ts", "**/*.d.ts"]
+}
diff --git a/libs/nestjs/password/CHANGELOG.md b/libs/nestjs/password/CHANGELOG.md
index 975d21609..b9ca92d8a 100644
--- a/libs/nestjs/password/CHANGELOG.md
+++ b/libs/nestjs/password/CHANGELOG.md
@@ -2,6 +2,40 @@
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
+# [2.1.0-next.1](https://github.com/tractr/traxion/compare/v2.1.0-next.0...v2.1.0-next.1) (2023-02-27)
+
+
+
+# [2.1.0-next.0](https://github.com/tractr/traxion/compare/v2.0.13...v2.1.0-next.0) (2023-02-27)
+
+
+
+## [2.0.11-next.3](https://github.com/tractr/traxion/compare/v2.0.11-next.2...v2.0.11-next.3) (2023-02-22)
+
+
+
+## [2.0.11-next.2](https://github.com/tractr/traxion/compare/v2.0.11-next.1...v2.0.11-next.2) (2023-02-22)
+
+
+
+## [2.0.11-next.1](https://github.com/tractr/traxion/compare/v2.0.11-next.0...v2.0.11-next.1) (2023-02-22)
+
+
+
+## [2.0.11-next.0](https://github.com/tractr/traxion/compare/v2.0.10...v2.0.11-next.0) (2023-02-22)
+
+
+### Bug Fixes
+
+* update mailer to use mailjet v6 ([2a4a060](https://github.com/tractr/traxion/commit/2a4a0607963235cbb859e8ff99794829f7eaaf58))
+
+
+### Features
+
+* clean authentication modules ([99b7db6](https://github.com/tractr/traxion/commit/99b7db69cc4f885ac885d147043003448895d66d))
+
+
+
## [2.0.13](https://github.com/tractr/traxion/compare/v2.0.12...v2.0.13) (2023-02-24)
diff --git a/libs/nestjs/password/package.json b/libs/nestjs/password/package.json
index 6d1acb780..b4ac79c1e 100644
--- a/libs/nestjs/password/package.json
+++ b/libs/nestjs/password/package.json
@@ -1,6 +1,6 @@
{
"name": "@trxn/nestjs-password",
- "version": "2.0.13",
+ "version": "2.1.0-next.1",
"repository": {
"type": "git",
"url": "https://github.com/tractr/traxion"
diff --git a/libs/nestjs/password/src/constants/index.ts b/libs/nestjs/password/src/constants/index.ts
index 626defce4..3bc138cf7 100644
--- a/libs/nestjs/password/src/constants/index.ts
+++ b/libs/nestjs/password/src/constants/index.ts
@@ -1 +1 @@
-export * from './reset-password.constant';
+export * from './password.contant';
diff --git a/libs/nestjs/password/src/constants/password.contant.ts b/libs/nestjs/password/src/constants/password.contant.ts
new file mode 100644
index 000000000..868350479
--- /dev/null
+++ b/libs/nestjs/password/src/constants/password.contant.ts
@@ -0,0 +1 @@
+export const ENCRYPTION_SERVICE = 'ENCRYPTION_SERVICE';
diff --git a/libs/nestjs/password/src/constants/reset-password.constant.ts b/libs/nestjs/password/src/constants/reset-password.constant.ts
deleted file mode 100644
index 9741d2011..000000000
--- a/libs/nestjs/password/src/constants/reset-password.constant.ts
+++ /dev/null
@@ -1 +0,0 @@
-export const DEFAULT_RESET_PASSWORD_LINK = `/password/reset/{{id}}/{{code}}`;
diff --git a/libs/nestjs/password/src/controllers/index.ts b/libs/nestjs/password/src/controllers/index.ts
index 040e4442e..94964fd83 100644
--- a/libs/nestjs/password/src/controllers/index.ts
+++ b/libs/nestjs/password/src/controllers/index.ts
@@ -1,2 +1 @@
-export * from './reset-password.controller';
export * from './password.controller';
diff --git a/libs/nestjs/password/src/controllers/password.controller.spec.ts b/libs/nestjs/password/src/controllers/password.controller.spec.ts
index 7f0a02a59..5f12a6457 100644
--- a/libs/nestjs/password/src/controllers/password.controller.spec.ts
+++ b/libs/nestjs/password/src/controllers/password.controller.spec.ts
@@ -10,8 +10,8 @@ import { User } from '@prisma/client';
import { mockDeep, MockProxy } from 'jest-mock-extended';
import * as request from 'supertest';
-import { PasswordService } from '../services';
import { PasswordController } from './password.controller';
+import { PasswordService } from '../services';
describe('Password Controller', () => {
let app: INestApplication;
diff --git a/libs/nestjs/password/src/dtos/index.ts b/libs/nestjs/password/src/dtos/index.ts
index 48e4257de..5709e5387 100644
--- a/libs/nestjs/password/src/dtos/index.ts
+++ b/libs/nestjs/password/src/dtos/index.ts
@@ -1,3 +1 @@
-export * from './password-reset-requested.dto';
-export * from './password-reset.dto';
export * from './password-update.dto';
diff --git a/libs/nestjs/password/src/errors/index.ts b/libs/nestjs/password/src/errors/index.ts
index a0b8e39c1..d9c97d12f 100644
--- a/libs/nestjs/password/src/errors/index.ts
+++ b/libs/nestjs/password/src/errors/index.ts
@@ -1,2 +1 @@
export * from './bad-password.error';
-export * from './bad-reset-code.error';
diff --git a/libs/nestjs/password/src/index.ts b/libs/nestjs/password/src/index.ts
index 77354e68c..dc69acaeb 100644
--- a/libs/nestjs/password/src/index.ts
+++ b/libs/nestjs/password/src/index.ts
@@ -1,4 +1,7 @@
+export * from './constants';
+export * from './controllers';
export * from './dtos';
+export * from './interfaces';
+export * from './services';
export * from './password.module';
export * from './password.module-definition';
-export * from './controllers';
diff --git a/libs/nestjs/password/src/interfaces/password-module-options.interface.ts b/libs/nestjs/password/src/interfaces/password-module-options.interface.ts
index f60351f4a..f2777b02d 100644
--- a/libs/nestjs/password/src/interfaces/password-module-options.interface.ts
+++ b/libs/nestjs/password/src/interfaces/password-module-options.interface.ts
@@ -1,49 +1,5 @@
import { JwtModuleOptions } from '@nestjs/jwt';
-import { Prisma } from '@prisma/client';
-
-import { EncryptionService } from '@trxn/nestjs-bcrypt';
-
-export type UserInfo = { id: string | number; email: string; password: string };
-
-export type ResetPasswordLinkFactory =
- | ((
- request: Record,
- resetCode: string,
- user: Record,
- ) => Promise | string)
- | string;
-
-export type ResetPasswordSendRequestEmail = (
- link: string,
- resetCode: string,
- user: Record,
-) => Promise | void;
-
-export type ResetPasswordSendRequestUpdated = (
- user: Record,
-) => Promise | void;
export class PasswordModuleOptions {
- resetPasswordExpiresIn?: string | number | undefined;
-
- resetPasswordLinkFactory?: ResetPasswordLinkFactory;
-
- resetPasswordSendEmail?: {
- request?: ResetPasswordSendRequestEmail;
- updated?: ResetPasswordSendRequestUpdated;
- };
-
- user?: {
- fields?: {
- id: string;
- email: string;
- password: string;
- };
- };
-
- userService!: Prisma.UserDelegate;
-
jwtModuleOptions?: JwtModuleOptions;
-
- encryptionService?: EncryptionService;
}
diff --git a/libs/nestjs/password/src/password.module-definition.ts b/libs/nestjs/password/src/password.module-definition.ts
index d0d481af2..93f5a07bc 100644
--- a/libs/nestjs/password/src/password.module-definition.ts
+++ b/libs/nestjs/password/src/password.module-definition.ts
@@ -2,9 +2,33 @@ import { ConfigurableModuleBuilder } from '@nestjs/common';
import { PasswordModuleOptions } from './interfaces';
+import {
+ addImportsAndProvidersExtra,
+ addProviderWithInjectionTokenExtra,
+ ImportsExtra,
+ ProvidersExtra,
+ ProviderWithInjectionToken,
+} from '@trxn/nestjs-core';
+import { USER_SERVICE, UserService } from '@trxn/nestjs-user';
+
export const {
ConfigurableModuleClass,
MODULE_OPTIONS_TOKEN,
ASYNC_OPTIONS_TYPE,
OPTIONS_TYPE,
-} = new ConfigurableModuleBuilder().build();
+} = new ConfigurableModuleBuilder()
+ .setExtras<
+ ImportsExtra &
+ ProvidersExtra & {
+ UserService?: ProviderWithInjectionToken<
+ typeof USER_SERVICE,
+ UserService
+ >;
+ }
+ >(
+ { imports: [], providers: [] },
+ addImportsAndProvidersExtra((definition, { UserService: User }) =>
+ addProviderWithInjectionTokenExtra(definition, USER_SERVICE, User),
+ ),
+ )
+ .build();
diff --git a/libs/nestjs/password/src/password.module.spec.ts b/libs/nestjs/password/src/password.module.spec.ts
index 3bb9fda0a..310c0e922 100644
--- a/libs/nestjs/password/src/password.module.spec.ts
+++ b/libs/nestjs/password/src/password.module.spec.ts
@@ -4,19 +4,20 @@ import { Prisma } from '@prisma/client';
import { mockDeep, MockProxy } from 'jest-mock-extended';
import { PasswordModule } from './password.module';
-import { PasswordService, ResetPasswordService } from './services';
+import { PasswordService } from './services';
+
+import { UserService } from '@trxn/nestjs-user';
describe('Password Module ', () => {
let app: INestApplication;
- let mockUserService: MockProxy>;
+ let mockUserService: MockProxy;
it('should load the module when using register', async () => {
- mockUserService = mockDeep>();
+ mockUserService = mockDeep();
const moduleFixture: TestingModule = await Test.createTestingModule({
imports: [
PasswordModule.register({
- resetPasswordLinkFactory: () => 'resetPasswordLinkFactory',
- userService: mockUserService,
+ providers: [{ provide: UserService, useValue: mockUserService }],
}),
],
providers: [],
@@ -27,19 +28,15 @@ describe('Password Module ', () => {
const passwordService = app.get(PasswordService);
expect(passwordService).toBeInstanceOf(PasswordService);
- const resetPasswordService = app.get(ResetPasswordService);
- expect(resetPasswordService).toBeInstanceOf(ResetPasswordService);
});
it('should load the module when using registerAsync', async () => {
- mockUserService = mockDeep>();
+ mockUserService = mockDeep();
const moduleFixture: TestingModule = await Test.createTestingModule({
imports: [
PasswordModule.registerAsync({
- useFactory: () => ({
- resetPasswordLinkFactory: () => 'resetPasswordLinkFactory',
- userService: mockUserService,
- }),
+ providers: [{ provide: UserService, useValue: mockUserService }],
+ useFactory: () => ({}),
}),
],
providers: [],
@@ -50,7 +47,5 @@ describe('Password Module ', () => {
const passwordService = app.get(PasswordService);
expect(passwordService).toBeInstanceOf(PasswordService);
- const resetPasswordService = app.get(ResetPasswordService);
- expect(resetPasswordService).toBeInstanceOf(ResetPasswordService);
});
});
diff --git a/libs/nestjs/password/src/password.module.ts b/libs/nestjs/password/src/password.module.ts
index 87a514d4c..3a5b22169 100644
--- a/libs/nestjs/password/src/password.module.ts
+++ b/libs/nestjs/password/src/password.module.ts
@@ -8,25 +8,15 @@ import {
MODULE_OPTIONS_TOKEN,
OPTIONS_TYPE,
} from './password.module-definition';
-import {
- HashService,
- PasswordService,
- ResetPasswordService,
- UserPasswordService,
-} from './services';
+import { HashService, PasswordService } from './services';
import { BcryptModule } from '@trxn/nestjs-bcrypt';
import { LoggerModule } from '@trxn/nestjs-core';
@Module({
imports: [LoggerModule, BcryptModule.register({})],
- providers: [
- PasswordService,
- ResetPasswordService,
- UserPasswordService,
- HashService,
- ],
- exports: [PasswordService, ResetPasswordService],
+ providers: [PasswordService, HashService],
+ exports: [PasswordService, HashService],
})
export class PasswordModule extends ConfigurableModuleClass {
static createModule(module: DynamicModule): DynamicModule {
@@ -58,12 +48,12 @@ export class PasswordModule extends ConfigurableModuleClass {
}
static register(options: typeof OPTIONS_TYPE): DynamicModule {
- const authenticationOptionsModule = super.register(options);
- return this.createModule(authenticationOptionsModule);
+ const passwordOptionsModule = super.register(options);
+ return this.createModule(passwordOptionsModule);
}
static registerAsync(options: typeof ASYNC_OPTIONS_TYPE): DynamicModule {
- const authenticationOptionsModule = super.registerAsync(options);
- return this.createModule(authenticationOptionsModule);
+ const passwordOptionsModule = super.registerAsync(options);
+ return this.createModule(passwordOptionsModule);
}
}
diff --git a/libs/nestjs/password/src/services/hash.service.spec.ts b/libs/nestjs/password/src/services/hash.service.spec.ts
index bb5b02fc3..b77af4bd6 100644
--- a/libs/nestjs/password/src/services/hash.service.spec.ts
+++ b/libs/nestjs/password/src/services/hash.service.spec.ts
@@ -2,9 +2,10 @@
import { Test, TestingModule } from '@nestjs/testing';
import { mockDeep, MockProxy, mockReset } from 'jest-mock-extended';
+import { HashService } from './hash.service';
+import { ENCRYPTION_SERVICE } from '../constants';
import { PasswordModuleOptions } from '../interfaces';
import { MODULE_OPTIONS_TOKEN } from '../password.module-definition';
-import { HashService } from './hash.service';
import { BcryptService } from '@trxn/nestjs-bcrypt';
@@ -12,16 +13,27 @@ describe('HashService', () => {
let hashService: HashService;
let mockPasswordModuleOptions: MockProxy;
let mockBcryptService: MockProxy;
+ let mockEncryptionService: MockProxy;
beforeEach(async () => {
- mockPasswordModuleOptions = mockDeep({});
+ mockPasswordModuleOptions = mockDeep(
+ {},
+ ) as MockProxy;
mockBcryptService = mockDeep();
+ mockEncryptionService = mockDeep();
const module: TestingModule = await Test.createTestingModule({
providers: [
HashService,
- { provide: MODULE_OPTIONS_TOKEN, useValue: mockPasswordModuleOptions },
+ {
+ provide: MODULE_OPTIONS_TOKEN,
+ useValue: mockPasswordModuleOptions,
+ },
{ provide: BcryptService, useValue: mockBcryptService },
+ {
+ provide: ENCRYPTION_SERVICE,
+ useValue: mockEncryptionService,
+ },
],
}).compile();
@@ -33,38 +45,71 @@ describe('HashService', () => {
mockReset(mockBcryptService);
});
- it('should be defined', () => {
- expect(hashService).toBeDefined();
- });
+ describe('use internal bcrypt provider', () => {
+ beforeEach(async () => {
+ mockPasswordModuleOptions = mockDeep({});
+ mockBcryptService = mockDeep();
+ mockEncryptionService = mockDeep();
- describe('compare', () => {
- it('should use the default BcryptService if no config is provided', async () => {
- mockPasswordModuleOptions.encryptionService = undefined;
- await hashService.compare('test', 'hash');
- expect(mockBcryptService.compare).toHaveBeenCalledWith('test', 'hash');
- });
- it('should use the EncryptionService if a config has been used', async () => {
- const encryptionService = mockDeep();
- mockPasswordModuleOptions.encryptionService = encryptionService;
+ const module: TestingModule = await Test.createTestingModule({
+ providers: [
+ HashService,
+ {
+ provide: MODULE_OPTIONS_TOKEN,
+ useValue: mockPasswordModuleOptions,
+ },
+ { provide: BcryptService, useValue: mockBcryptService },
+ ],
+ }).compile();
+ hashService = module.get(HashService);
+ });
+ it('should use the default BcryptService.compare', async () => {
await hashService.compare('test', 'hash');
- expect(mockBcryptService.compare).toHaveBeenCalledTimes(0);
- expect(encryptionService.compare).toHaveBeenCalledWith('test', 'hash');
+ expect(mockBcryptService.compare).toHaveBeenCalledWith('test', 'hash');
+ expect(mockEncryptionService.compare).not.toHaveBeenCalled();
});
- });
- describe('hash', () => {
- it('should use the default BcryptService if no config is provided', async () => {
- mockPasswordModuleOptions.encryptionService = undefined;
+ it('should use the default BcryptService.hash', async () => {
await hashService.hash('test');
expect(mockBcryptService.hash).toHaveBeenCalledWith('test');
+ expect(mockEncryptionService.hash).not.toHaveBeenCalled();
});
- it('should use the EncryptionService if a config has been used', async () => {
- const encryptionService = mockDeep();
- mockPasswordModuleOptions.encryptionService = encryptionService;
+ });
+ describe('use external encryption provider', () => {
+ beforeEach(async () => {
+ mockPasswordModuleOptions = mockDeep({});
+ mockBcryptService = mockDeep();
+ mockEncryptionService = mockDeep();
+
+ const module: TestingModule = await Test.createTestingModule({
+ providers: [
+ HashService,
+ {
+ provide: MODULE_OPTIONS_TOKEN,
+ useValue: mockPasswordModuleOptions,
+ },
+ { provide: BcryptService, useValue: mockBcryptService },
+ {
+ provide: ENCRYPTION_SERVICE,
+ useValue: mockEncryptionService,
+ },
+ ],
+ }).compile();
+ hashService = module.get(HashService);
+ });
+ it('should use the EncryptionService.compare', async () => {
+ await hashService.compare('test', 'hash');
+ expect(mockBcryptService.compare).not.toHaveBeenCalled();
+ expect(mockEncryptionService.compare).toHaveBeenCalledWith(
+ 'test',
+ 'hash',
+ );
+ });
+ it('should use the EncryptionService.hash', async () => {
await hashService.hash('test');
- expect(mockBcryptService.hash).toHaveBeenCalledTimes(0);
- expect(encryptionService.hash).toHaveBeenCalledWith('test');
+ expect(mockBcryptService.hash).not.toHaveBeenCalled();
+ expect(mockEncryptionService.hash).toHaveBeenCalledWith('test');
});
});
});
diff --git a/libs/nestjs/password/src/services/hash.service.ts b/libs/nestjs/password/src/services/hash.service.ts
index de8582243..b32a0dd65 100644
--- a/libs/nestjs/password/src/services/hash.service.ts
+++ b/libs/nestjs/password/src/services/hash.service.ts
@@ -1,20 +1,19 @@
-import { Inject, Injectable } from '@nestjs/common';
+import { Inject, Injectable, Optional } from '@nestjs/common';
-import { PasswordModuleOptions } from '../interfaces';
-import { MODULE_OPTIONS_TOKEN } from '../password.module-definition';
+import { ENCRYPTION_SERVICE } from '../constants';
import { BcryptService, EncryptionService } from '@trxn/nestjs-bcrypt';
@Injectable()
export class HashService implements EncryptionService {
constructor(
- @Inject(MODULE_OPTIONS_TOKEN)
- private readonly passwordModuleOptions: PasswordModuleOptions,
private readonly bcryptService: BcryptService,
- ) {}
- get encryptionService(): EncryptionService {
- return this.passwordModuleOptions.encryptionService || this.bcryptService;
+ @Optional()
+ @Inject(ENCRYPTION_SERVICE)
+ private readonly encryptionService: EncryptionService,
+ ) {
+ this.encryptionService = this.encryptionService || this.bcryptService;
}
async hash(value: string): Promise {
diff --git a/libs/nestjs/password/src/services/index.ts b/libs/nestjs/password/src/services/index.ts
index f8182d8ff..7848e7859 100644
--- a/libs/nestjs/password/src/services/index.ts
+++ b/libs/nestjs/password/src/services/index.ts
@@ -1,4 +1,2 @@
export * from './hash.service';
export * from './password.service';
-export * from './reset-password.service';
-export * from './user-password.service';
diff --git a/libs/nestjs/password/src/services/password.service.spec.ts b/libs/nestjs/password/src/services/password.service.spec.ts
index f5912cd79..04f154e64 100644
--- a/libs/nestjs/password/src/services/password.service.spec.ts
+++ b/libs/nestjs/password/src/services/password.service.spec.ts
@@ -1,26 +1,26 @@
import { Test, TestingModule } from '@nestjs/testing';
import { mockDeep, MockProxy } from 'jest-mock-extended';
-import { BadPasswordError } from '../errors';
import { HashService } from './hash.service';
import { PasswordService } from './password.service';
-import { UserPasswordService } from './user-password.service';
+import { BadPasswordError } from '../errors';
import { UserNotFoundError } from '@trxn/nestjs-authentication';
+import { UserService } from '@trxn/nestjs-user';
describe('PasswordService', () => {
let passwordService: PasswordService;
- let mockUserPasswordService: MockProxy;
+ let mockUserService: MockProxy;
let mockHashService: MockProxy;
beforeEach(async () => {
- mockUserPasswordService = mockDeep();
+ mockUserService = mockDeep();
mockHashService = mockDeep();
const module: TestingModule = await Test.createTestingModule({
providers: [
PasswordService,
- { provide: UserPasswordService, useValue: mockUserPasswordService },
+ { provide: UserService, useValue: mockUserService },
{ provide: HashService, useValue: mockHashService },
],
}).compile();
@@ -34,7 +34,7 @@ describe('PasswordService', () => {
describe('updatePassword', () => {
it('should update the password', async () => {
- mockUserPasswordService.getUserFromId.mockResolvedValue({
+ mockUserService.findUserById.mockResolvedValue({
id: '1',
password: 'old',
email: 'email',
@@ -44,14 +44,11 @@ describe('PasswordService', () => {
await passwordService.updatePassword('1', 'old', 'new');
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(mockUserPasswordService.updateUserPassword).toHaveBeenCalledWith(
- '1',
- 'new',
- );
+ expect(mockUserService.updatePassword).toHaveBeenCalledWith('1', 'new');
});
it('should throw if the user has not been found', async () => {
- mockUserPasswordService.getUserFromId.mockResolvedValue(null);
+ mockUserService.findUserById.mockResolvedValue(null);
await expect(async () =>
passwordService.updatePassword('1', 'old', 'new'),
@@ -59,7 +56,7 @@ describe('PasswordService', () => {
});
it('should throw if the old password is not right', async () => {
- mockUserPasswordService.getUserFromId.mockResolvedValue({
+ mockUserService.findUserById.mockResolvedValue({
id: '1',
password: 'password',
email: 'email',
diff --git a/libs/nestjs/password/src/services/password.service.ts b/libs/nestjs/password/src/services/password.service.ts
index 694a973b8..fbe7742f7 100644
--- a/libs/nestjs/password/src/services/password.service.ts
+++ b/libs/nestjs/password/src/services/password.service.ts
@@ -1,24 +1,24 @@
import { Injectable } from '@nestjs/common';
-import { BadPasswordError } from '../errors';
import { HashService } from './hash.service';
-import { UserPasswordService } from './user-password.service';
+import { BadPasswordError } from '../errors';
import { UserNotFoundError } from '@trxn/nestjs-authentication';
+import { UserId, UserService } from '@trxn/nestjs-user';
@Injectable()
export class PasswordService {
constructor(
- private readonly userPasswordService: UserPasswordService,
+ private readonly userService: UserService,
private readonly hashService: HashService,
) {}
async updatePassword(
- userId: string,
+ userId: UserId,
oldPassword: string,
newPassword: string,
) {
- const user = await this.userPasswordService.getUserFromId(userId);
+ const user = await this.userService.findUserById(userId);
if (!user) {
throw new UserNotFoundError();
@@ -32,6 +32,6 @@ export class PasswordService {
throw new BadPasswordError();
}
- await this.userPasswordService.updateUserPassword(userId, newPassword);
+ await this.userService.updatePassword(userId, newPassword);
}
}
diff --git a/libs/nestjs/password/src/services/reset-password.service.ts b/libs/nestjs/password/src/services/reset-password.service.ts
deleted file mode 100644
index 251e23c8d..000000000
--- a/libs/nestjs/password/src/services/reset-password.service.ts
+++ /dev/null
@@ -1,122 +0,0 @@
-import { Inject, Injectable } from '@nestjs/common';
-import { REQUEST } from '@nestjs/core';
-import { JwtService } from '@nestjs/jwt';
-import { User } from '@prisma/client';
-
-import { DEFAULT_RESET_PASSWORD_LINK } from '../constants';
-import { BadResetCodeError } from '../errors';
-import { PasswordModuleOptions, UserInfo } from '../interfaces';
-import { MODULE_OPTIONS_TOKEN } from '../password.module-definition';
-import { UserPasswordService } from './user-password.service';
-
-import { UserNotFoundError } from '@trxn/nestjs-authentication';
-
-@Injectable()
-export class ResetPasswordService {
- constructor(
- @Inject(REQUEST) private request: Record,
- @Inject(MODULE_OPTIONS_TOKEN)
- private readonly passwordConfig: PasswordModuleOptions,
- private readonly jwtService: JwtService,
- private readonly userPasswordService: UserPasswordService,
- ) {}
-
- /**
- * Send a reset code to the user's email
- * @param user User The user to send the reset code to (id email and password are required)
- */
- async requestResetPassword(
- login: string,
- ): Promise<{ link: string; resetCode: string }> {
- const user = await this.userPasswordService.getUserFromLogin(login);
-
- if (!user) {
- throw new UserNotFoundError();
- }
-
- // We first generate the reset code and get a JWT Token
- const resetCode = this.createResetCode(user);
-
- const resetPasswordLink =
- this.passwordConfig.resetPasswordLinkFactory ||
- DEFAULT_RESET_PASSWORD_LINK;
-
- const link = await Promise.resolve(
- typeof resetPasswordLink === 'string'
- ? resetPasswordLink
- .replace('{{id}}', `${user.id}`)
- .replace('{{code}}', resetCode)
- : resetPasswordLink(
- this.request,
- resetCode,
- this.userPasswordService.getUserFromUserInfo(user),
- ),
- );
-
- if (this.passwordConfig.resetPasswordSendEmail?.request) {
- // We call the method to send the email and wait for the response
- await Promise.resolve(
- this.passwordConfig.resetPasswordSendEmail.request(
- link,
- resetCode,
- this.userPasswordService.getUserFromUserInfo(user),
- ),
- );
- }
-
- return { link, resetCode };
- }
-
- getUserSecret({ id, email, password }: UserInfo) {
- return `${id}-${password}-${email}`;
- }
-
- createResetCode({ id, email, password }: UserInfo): string {
- return this.jwtService.sign(
- { sub: id },
- {
- expiresIn: this.passwordConfig.resetPasswordExpiresIn || '24h',
- secret: this.getUserSecret({ id, email, password }),
- },
- );
- }
-
- verifyResetCode(
- { id, email, password }: UserInfo,
- resetCode: string,
- ): Promise<{ sub: User['id'] }> {
- return this.jwtService.verifyAsync(resetCode, {
- secret: this.getUserSecret({ id, email, password }),
- });
- }
-
- async reset(
- userId: string | number,
- resetCode: string,
- resetPassword: string,
- ): Promise {
- const user = await this.userPasswordService.getUserFromId(userId);
-
- if (!user) {
- throw new UserNotFoundError();
- }
-
- try {
- const payload = await this.verifyResetCode(user, resetCode);
- if (payload.sub !== user.id) throw new Error();
- } catch {
- throw new BadResetCodeError();
- }
-
- await this.userPasswordService.updateUserPassword(userId, resetPassword);
-
- if (this.passwordConfig.resetPasswordSendEmail?.updated) {
- // We call the method to send the email and wait for the response
- await Promise.resolve(
- this.passwordConfig.resetPasswordSendEmail.updated(
- this.userPasswordService.getUserFromUserInfo(user),
- ),
- );
- }
- }
-}
diff --git a/libs/nestjs/password/src/services/user-password.service.spec.ts b/libs/nestjs/password/src/services/user-password.service.spec.ts
deleted file mode 100644
index 664532b32..000000000
--- a/libs/nestjs/password/src/services/user-password.service.spec.ts
+++ /dev/null
@@ -1,272 +0,0 @@
-/* eslint-disable @typescript-eslint/unbound-method */
-
-import { Test, TestingModule } from '@nestjs/testing';
-import { Prisma, User } from '@prisma/client';
-import { mockDeep, MockProxy, mockReset } from 'jest-mock-extended';
-
-import { PasswordModuleOptions } from '../interfaces';
-import { MODULE_OPTIONS_TOKEN } from '../password.module-definition';
-import { UserPasswordService } from './user-password.service';
-
-import { LoggerModule } from '@trxn/nestjs-core';
-
-describe('UserPasswordService', () => {
- let userPasswordService: UserPasswordService;
- let mockPasswordModuleOptions: MockProxy;
- let mockUserService: MockProxy>;
-
- beforeEach(async () => {
- mockUserService = mockDeep>();
- mockPasswordModuleOptions = mockDeep({
- userService: mockUserService,
- });
-
- const module: TestingModule = await Test.createTestingModule({
- imports: [LoggerModule],
- providers: [
- UserPasswordService,
- {
- provide: MODULE_OPTIONS_TOKEN,
- useValue: mockPasswordModuleOptions,
- },
- ],
- }).compile();
-
- userPasswordService = module.get(UserPasswordService);
- });
-
- afterEach(() => {
- mockReset(mockPasswordModuleOptions);
- mockReset(mockUserService);
- });
-
- it('should be defined', () => {
- expect(userPasswordService).toBeDefined();
- });
-
- it('should get the fields from the configuration', async () => {
- mockPasswordModuleOptions.user = undefined;
-
- let res = userPasswordService.getUserFromUserInfo({
- id: 'id',
- email: 'email',
- password: 'password',
- });
-
- expect(res).toEqual({
- id: 'id',
- email: 'email',
- password: 'password',
- });
-
- mockPasswordModuleOptions.user = {};
-
- res = userPasswordService.getUserFromUserInfo({
- id: 'id',
- email: 'email',
- password: 'password',
- });
-
- expect(res).toEqual({
- id: 'id',
- email: 'email',
- password: 'password',
- });
- });
-
- describe('getUserFromUserInfo', () => {
- it('should get the user from the user info', async () => {
- const { id, email, password } = {
- id: 'id',
- email: 'email',
- password: 'password',
- };
-
- mockPasswordModuleOptions.user = {
- fields: {
- id: 'idField',
- email: 'emailField',
- password: 'passwordField',
- },
- };
-
- const result = userPasswordService.getUserFromUserInfo({
- id,
- email,
- password,
- });
- expect(result).toEqual({
- idField: id,
- emailField: email,
- passwordField: password,
- });
- });
- });
- describe('getUserFromId', () => {
- it('should return a user with the default options', async () => {
- mockUserService.findUnique.mockResolvedValue({
- id: '1',
- email: 'email',
- password: 'password',
- otherField: 'otherField',
- } as unknown as User);
-
- const res = await userPasswordService.getUserFromId('1');
-
- expect(res).toEqual({
- id: '1',
- email: 'email',
- password: 'password',
- });
-
- expect(mockUserService.findUnique).toHaveBeenCalledWith({
- where: { id: '1' },
- select: { id: true, email: true, password: true },
- });
- });
-
- it('should return a user using the options set during the module configuration', async () => {
- mockPasswordModuleOptions.user = {
- fields: {
- id: 'idField',
- email: 'loginField',
- password: 'passwordField',
- },
- };
-
- mockUserService.findUnique.mockResolvedValue({
- idField: '1',
- loginField: 'email',
- passwordField: 'password',
- otherField: 'otherField',
- } as unknown as User);
-
- const res = await userPasswordService.getUserFromId('1');
-
- expect(res).toEqual({
- id: '1',
- email: 'email',
- password: 'password',
- });
-
- expect(mockUserService.findUnique).toHaveBeenCalledWith({
- where: { idField: '1' },
- select: { idField: true, loginField: true, passwordField: true },
- });
- });
-
- it('should return null if the user is not found from findUnique', async () => {
- mockUserService.findUnique.mockResolvedValue(null);
- const res = await userPasswordService.getUserFromId('1');
-
- expect(res).toBeNull();
- });
-
- it('should return null if findUnique does not return all the information needed', async () => {
- mockUserService.findUnique.mockResolvedValue({
- id: 'id ',
- } as unknown as User);
- const res = await userPasswordService.getUserFromId('1');
-
- expect(res).toBeNull();
- });
- });
-
- describe('getUserFromLogin', () => {
- it('should return a user with the default options', async () => {
- mockUserService.findUnique.mockResolvedValue({
- id: '1',
- email: 'email',
- password: 'password',
- otherField: 'otherField',
- } as unknown as User);
-
- const res = await userPasswordService.getUserFromLogin('email');
-
- expect(res).toEqual({
- id: '1',
- email: 'email',
- password: 'password',
- });
-
- expect(mockUserService.findUnique).toHaveBeenCalledWith({
- where: { email: 'email' },
- select: { id: true, email: true, password: true },
- });
- });
-
- it('should return a user using the options set during the module configuration', async () => {
- mockPasswordModuleOptions.user = {
- fields: {
- id: 'idField',
- email: 'loginField',
- password: 'passwordField',
- },
- };
-
- mockUserService.findUnique.mockResolvedValue({
- idField: '1',
- loginField: 'email',
- passwordField: 'password',
- otherField: 'otherField',
- } as unknown as User);
-
- const res = await userPasswordService.getUserFromLogin('email');
-
- expect(res).toEqual({
- id: '1',
- email: 'email',
- password: 'password',
- });
-
- expect(mockUserService.findUnique).toHaveBeenCalledWith({
- where: { loginField: 'email' },
- select: { idField: true, loginField: true, passwordField: true },
- });
- });
-
- it('should return null if the user is not found from findUnique', async () => {
- mockUserService.findUnique.mockResolvedValue(null);
- const res = await userPasswordService.getUserFromLogin('email');
-
- expect(res).toBeNull();
- });
-
- it('should return null if findUnique does not return all the information needed', async () => {
- mockUserService.findUnique.mockResolvedValue({
- id: 'id ',
- } as unknown as User);
- const res = await userPasswordService.getUserFromLogin('email');
-
- expect(res).toBeNull();
- });
- });
-
- describe('updateUserPassword', () => {
- it('should return a user with the default options', async () => {
- await userPasswordService.updateUserPassword('1', 'new');
-
- expect(mockUserService.update).toHaveBeenCalledWith({
- where: { id: '1' },
- data: { password: 'new' },
- });
- });
-
- it('should return a user using the options set during the module configuration', async () => {
- mockPasswordModuleOptions.user = {
- fields: {
- id: 'idField',
- email: 'loginField',
- password: 'passwordField',
- },
- };
-
- await userPasswordService.updateUserPassword('1', 'new');
-
- expect(mockUserService.update).toHaveBeenCalledWith({
- where: { idField: '1' },
- data: { passwordField: 'new' },
- });
- });
- });
-});
diff --git a/libs/nestjs/password/src/services/user-password.service.ts b/libs/nestjs/password/src/services/user-password.service.ts
deleted file mode 100644
index 7182a10e2..000000000
--- a/libs/nestjs/password/src/services/user-password.service.ts
+++ /dev/null
@@ -1,102 +0,0 @@
-import { Inject, Injectable, Logger } from '@nestjs/common';
-
-import { PasswordModuleOptions, UserInfo } from '../interfaces';
-import { MODULE_OPTIONS_TOKEN } from '../password.module-definition';
-
-import { LoggerService } from '@trxn/nestjs-core';
-
-@Injectable()
-export class UserPasswordService {
- constructor(
- @Inject(MODULE_OPTIONS_TOKEN)
- private readonly passwordConfig: PasswordModuleOptions,
- @Inject(Logger) private readonly logger: LoggerService,
- ) {
- logger.setContext(UserPasswordService.name);
- }
-
- private get userService() {
- return this.passwordConfig.userService;
- }
-
- private get fields() {
- return {
- id: 'id',
- email: 'email',
- password: 'password',
- ...(this.passwordConfig.user?.fields || {}),
- };
- }
-
- getUserFromUserInfo(user: UserInfo) {
- return {
- [this.fields.id]: user.id,
- [this.fields.email]: user.email,
- [this.fields.password]: user.password,
- };
- }
-
- checkUserInfo(user: UserInfo | null): UserInfo | null {
- if (!user) {
- this.logger.debug(`User not found`);
- return null;
- }
-
- const { id, email, password } = {
- id: user[this.fields.id as 'id'],
- email: user[this.fields.email as 'email'],
- password: user[this.fields.password as 'password'],
- };
-
- if (!id || !password || !email) {
- this.logger.debug(`id, password or email information not found`, user);
- return null;
- }
-
- return { id, email, password };
- }
-
- async getUserFromLogin(login: string): Promise {
- this.logger.debug(`Getting user from login ${login}`);
- const user = (await this.userService.findUnique({
- where: {
- [this.fields.email]: login,
- },
- select: {
- [this.fields.id]: true,
- [this.fields.email]: true,
- [this.fields.password]: true,
- },
- })) as UserInfo | null;
-
- return this.checkUserInfo(user);
- }
-
- async getUserFromId(userId: string | number): Promise {
- this.logger.debug(`Getting user from id ${userId}`);
- const user = (await this.userService.findUnique({
- where: {
- [this.fields.id]: userId,
- },
- select: {
- [this.fields.id]: true,
- [this.fields.email]: true,
- [this.fields.password]: true,
- },
- })) as UserInfo | null;
-
- return this.checkUserInfo(user);
- }
-
- updateUserPassword(userId: string | number, newPassword: string) {
- this.logger.debug(`Updating user password for id ${userId}`);
- return this.userService.update({
- where: {
- [this.fields.id]: userId,
- },
- data: {
- [this.fields.password]: newPassword,
- },
- });
- }
-}
diff --git a/libs/nestjs/request-timestamp/CHANGELOG.md b/libs/nestjs/request-timestamp/CHANGELOG.md
index 6294d5622..f5ab7619f 100644
--- a/libs/nestjs/request-timestamp/CHANGELOG.md
+++ b/libs/nestjs/request-timestamp/CHANGELOG.md
@@ -2,6 +2,14 @@
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
+# [2.1.0-next.1](https://github.com/tractr/traxion/compare/v2.1.0-next.0...v2.1.0-next.1) (2023-02-27)
+
+
+
+# [2.1.0-next.0](https://github.com/tractr/traxion/compare/v2.0.13...v2.1.0-next.0) (2023-02-27)
+
+
+
## [2.0.13](https://github.com/tractr/traxion/compare/v2.0.12...v2.0.13) (2023-02-24)
diff --git a/libs/nestjs/request-timestamp/package.json b/libs/nestjs/request-timestamp/package.json
index 2803c9da8..c9ee6fcfb 100644
--- a/libs/nestjs/request-timestamp/package.json
+++ b/libs/nestjs/request-timestamp/package.json
@@ -1,6 +1,6 @@
{
"name": "@trxn/nestjs-request-timestamp",
- "version": "2.0.13",
+ "version": "2.1.0-next.1",
"repository": {
"type": "git",
"url": "https://github.com/tractr/traxion"
diff --git a/libs/nestjs/reset-password/.babelrc b/libs/nestjs/reset-password/.babelrc
new file mode 100644
index 000000000..b63f0528f
--- /dev/null
+++ b/libs/nestjs/reset-password/.babelrc
@@ -0,0 +1,10 @@
+{
+ "presets": [
+ [
+ "@nrwl/js/babel",
+ {
+ "useBuiltIns": "usage"
+ }
+ ]
+ ]
+}
diff --git a/libs/nestjs/reset-password/.eslintrc.json b/libs/nestjs/reset-password/.eslintrc.json
new file mode 100644
index 000000000..3456be9b9
--- /dev/null
+++ b/libs/nestjs/reset-password/.eslintrc.json
@@ -0,0 +1,18 @@
+{
+ "extends": ["../../../.eslintrc.json"],
+ "ignorePatterns": ["!**/*"],
+ "overrides": [
+ {
+ "files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
+ "rules": {}
+ },
+ {
+ "files": ["*.ts", "*.tsx"],
+ "rules": {}
+ },
+ {
+ "files": ["*.js", "*.jsx"],
+ "rules": {}
+ }
+ ]
+}
diff --git a/libs/nestjs/reset-password/CHANGELOG.md b/libs/nestjs/reset-password/CHANGELOG.md
new file mode 100644
index 000000000..21de4d95e
--- /dev/null
+++ b/libs/nestjs/reset-password/CHANGELOG.md
@@ -0,0 +1,61 @@
+# Changelog
+
+This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
+
+# [2.1.0-next.1](https://github.com/tractr/traxion/compare/v2.1.0-next.0...v2.1.0-next.1) (2023-02-27)
+
+
+
+# [2.1.0-next.0](https://github.com/tractr/traxion/compare/v2.0.13...v2.1.0-next.0) (2023-02-27)
+
+
+
+## [2.0.11-next.3](https://github.com/tractr/traxion/compare/v2.0.11-next.2...v2.0.11-next.3) (2023-02-22)
+
+
+
+## [2.0.11-next.2](https://github.com/tractr/traxion/compare/v2.0.11-next.1...v2.0.11-next.2) (2023-02-22)
+
+
+
+## [2.0.11-next.1](https://github.com/tractr/traxion/compare/v2.0.11-next.0...v2.0.11-next.1) (2023-02-22)
+
+
+
+## [2.0.11-next.0](https://github.com/tractr/traxion/compare/v2.0.10...v2.0.11-next.0) (2023-02-22)
+
+
+### Bug Fixes
+
+* resolve conversation and make the api start without settings env ([87d4465](https://github.com/tractr/traxion/commit/87d446509dd3c182c92a9d269dfbe24a826899ec))
+
+
+### Features
+
+* clean authentication modules ([99b7db6](https://github.com/tractr/traxion/commit/99b7db69cc4f885ac885d147043003448895d66d))
+
+
+
+## [2.0.11-next.3](https://github.com/tractr/traxion/compare/v2.0.11-next.2...v2.0.11-next.3) (2023-02-22)
+
+
+
+## [2.0.11-next.2](https://github.com/tractr/traxion/compare/v2.0.11-next.1...v2.0.11-next.2) (2023-02-22)
+
+
+
+## [2.0.11-next.1](https://github.com/tractr/traxion/compare/v2.0.11-next.0...v2.0.11-next.1) (2023-02-22)
+
+
+
+## [2.0.11-next.0](https://github.com/tractr/traxion/compare/v2.0.10...v2.0.11-next.0) (2023-02-22)
+
+
+### Bug Fixes
+
+* resolve conversation and make the api start without settings env ([87d4465](https://github.com/tractr/traxion/commit/87d446509dd3c182c92a9d269dfbe24a826899ec))
+
+
+### Features
+
+* clean authentication modules ([99b7db6](https://github.com/tractr/traxion/commit/99b7db69cc4f885ac885d147043003448895d66d))
diff --git a/libs/nestjs/reset-password/README.md b/libs/nestjs/reset-password/README.md
new file mode 100644
index 000000000..9b704b047
--- /dev/null
+++ b/libs/nestjs/reset-password/README.md
@@ -0,0 +1,12 @@
+# nestjs-reset-password
+
+This library was generated with [Nx](https://nx.dev).
+
+## Building
+
+Run `nx build nestjs-reset-password` to build the library.
+
+## Running unit tests
+
+Run `nx test nestjs-reset-password` to execute the unit tests via
+[Jest](https://jestjs.io).
diff --git a/libs/nestjs/reset-password/jest.config.ts b/libs/nestjs/reset-password/jest.config.ts
new file mode 100644
index 000000000..dced5e778
--- /dev/null
+++ b/libs/nestjs/reset-password/jest.config.ts
@@ -0,0 +1,16 @@
+/* eslint-disable */
+export default {
+ displayName: 'nestjs-reset-password',
+ preset: '../../../jest.preset.js',
+ globals: {
+ 'ts-jest': {
+ tsconfig: '/tsconfig.spec.json',
+ },
+ },
+ testEnvironment: 'node',
+ transform: {
+ '^.+\\.[tj]s$': 'ts-jest',
+ },
+ moduleFileExtensions: ['ts', 'js', 'html'],
+ coverageDirectory: '../../../coverage/libs/nestjs/reset-password',
+};
diff --git a/libs/nestjs/reset-password/package.json b/libs/nestjs/reset-password/package.json
new file mode 100644
index 000000000..508d3541e
--- /dev/null
+++ b/libs/nestjs/reset-password/package.json
@@ -0,0 +1,13 @@
+{
+ "name": "@trxn/nestjs-reset-password",
+ "version": "2.1.0-next.1",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/tractr/traxion"
+ },
+ "type": "commonjs",
+ "publishConfig": {
+ "access": "public",
+ "registry": "https://registry.npmjs.org/"
+ }
+}
diff --git a/libs/nestjs/reset-password/project.json b/libs/nestjs/reset-password/project.json
new file mode 100644
index 000000000..d544bc13d
--- /dev/null
+++ b/libs/nestjs/reset-password/project.json
@@ -0,0 +1,53 @@
+{
+ "$schema": "../../../node_modules/nx/schemas/project-schema.json",
+ "name": "nestjs-reset-password",
+ "projectType": "library",
+ "sourceRoot": "libs/nestjs/reset-password/src",
+ "tags": [],
+ "targets": {
+ "build": {
+ "executor": "@nrwl/js:tsc",
+ "options": {
+ "assets": ["libs/nestjs/reset-password/*.md"],
+ "main": "libs/nestjs/reset-password/src/index.ts",
+ "outputPath": "dist/libs/nestjs/reset-password",
+ "packageJson": "libs/nestjs/reset-password/package.json",
+ "tsConfig": "libs/nestjs/reset-password/tsconfig.lib.json"
+ },
+ "outputs": ["{options.outputPath}"]
+ },
+ "lint": {
+ "executor": "@nrwl/linter:eslint",
+ "options": {
+ "lintFilePatterns": ["libs/nestjs/reset-password/**/*.ts"]
+ },
+ "outputs": ["{options.outputFile}"]
+ },
+ "publish": {
+ "executor": "ngx-deploy-npm:deploy",
+ "options": {
+ "access": "public"
+ }
+ },
+ "test": {
+ "configurations": {
+ "ci": {
+ "ci": true,
+ "codeCoverage": true
+ }
+ },
+ "executor": "@nrwl/jest:jest",
+ "options": {
+ "jestConfig": "libs/nestjs/reset-password/jest.config.ts",
+ "passWithNoTests": true
+ },
+ "outputs": ["{workspaceRoot}/coverage/{projectRoot}"]
+ },
+ "update-peer-dependencies": {
+ "executor": "./dist/libs/schematics:update-peer-dependencies",
+ "options": {
+ "packageJsonPath": "{workspaceRoot}/dist/libs/nestjs/reset-password/package.json"
+ }
+ }
+ }
+}
diff --git a/libs/nestjs/reset-password/src/constants/index.ts b/libs/nestjs/reset-password/src/constants/index.ts
new file mode 100644
index 000000000..626defce4
--- /dev/null
+++ b/libs/nestjs/reset-password/src/constants/index.ts
@@ -0,0 +1 @@
+export * from './reset-password.constant';
diff --git a/libs/nestjs/mailer/src/lib/constants/reset-password-send-email.constant.ts b/libs/nestjs/reset-password/src/constants/reset-password.constant.ts
similarity index 81%
rename from libs/nestjs/mailer/src/lib/constants/reset-password-send-email.constant.ts
rename to libs/nestjs/reset-password/src/constants/reset-password.constant.ts
index 2a8ee8de0..ccf1bcf9f 100644
--- a/libs/nestjs/mailer/src/lib/constants/reset-password-send-email.constant.ts
+++ b/libs/nestjs/reset-password/src/constants/reset-password.constant.ts
@@ -1,4 +1,6 @@
-export const DEFAULT_RESET_HTML = `
+export const DEFAULT_RESET_PASSWORD_LINK = `/password/reset/{{id}}/{{code}}`;
+
+export const DEFAULT_RESET_PASSWORD_REQUEST_EMAIL_HTML = `
@@ -15,7 +17,7 @@ export const DEFAULT_RESET_HTML = `
`;
-export const DEFAULT_UPDATED_HTML = `
+export const DEFAULT_RESET_PASSWORD_SUCCEED_EMAIL_HTML = `
diff --git a/libs/nestjs/reset-password/src/controllers/index.ts b/libs/nestjs/reset-password/src/controllers/index.ts
new file mode 100644
index 000000000..019ebf075
--- /dev/null
+++ b/libs/nestjs/reset-password/src/controllers/index.ts
@@ -0,0 +1 @@
+export * from './reset-password.controller';
diff --git a/libs/nestjs/password/src/controllers/reset-password.controller.spec.ts b/libs/nestjs/reset-password/src/controllers/reset-password.controller.spec.ts
similarity index 97%
rename from libs/nestjs/password/src/controllers/reset-password.controller.spec.ts
rename to libs/nestjs/reset-password/src/controllers/reset-password.controller.spec.ts
index e3be84923..2fb215212 100644
--- a/libs/nestjs/password/src/controllers/reset-password.controller.spec.ts
+++ b/libs/nestjs/reset-password/src/controllers/reset-password.controller.spec.ts
@@ -3,9 +3,9 @@ import { Test, TestingModule } from '@nestjs/testing';
import { mockDeep, MockProxy } from 'jest-mock-extended';
import * as request from 'supertest';
+import { ResetPasswordController } from './reset-password.controller';
import { BadResetCodeError } from '../errors';
import { ResetPasswordService } from '../services';
-import { ResetPasswordController } from './reset-password.controller';
import { UserNotFoundError } from '@trxn/nestjs-authentication';
@@ -46,11 +46,11 @@ describe('ResetPassword Controller', () => {
await request(app.getHttpServer())
.post('/password/reset')
.send({
- login: 'login',
+ id: '1',
})
.expect(204);
- expect(spyRequestUpdatePassword).toHaveBeenCalledWith('login');
+ expect(spyRequestUpdatePassword).toHaveBeenCalledWith('1');
});
it('should swallow the error if a user is not found', async () => {
diff --git a/libs/nestjs/password/src/controllers/reset-password.controller.ts b/libs/nestjs/reset-password/src/controllers/reset-password.controller.ts
similarity index 90%
rename from libs/nestjs/password/src/controllers/reset-password.controller.ts
rename to libs/nestjs/reset-password/src/controllers/reset-password.controller.ts
index 3753ae889..800dd024b 100644
--- a/libs/nestjs/password/src/controllers/reset-password.controller.ts
+++ b/libs/nestjs/reset-password/src/controllers/reset-password.controller.ts
@@ -22,10 +22,10 @@ export class ResetPasswordController {
@Post()
@HttpCode(204)
async resetRequested(
- @Body() { login }: PasswordResetRequestedDto,
+ @Body() { id }: PasswordResetRequestedDto,
): Promise {
try {
- await this.resetPasswordService.requestResetPassword(login);
+ await this.resetPasswordService.requestResetPassword(id);
} catch (e) {
// We should never send information about a user not found
if (e instanceof UserNotFoundError) return;
diff --git a/libs/nestjs/reset-password/src/dtos/index.ts b/libs/nestjs/reset-password/src/dtos/index.ts
new file mode 100644
index 000000000..20e0864ee
--- /dev/null
+++ b/libs/nestjs/reset-password/src/dtos/index.ts
@@ -0,0 +1,2 @@
+export * from './password-reset-requested.dto';
+export * from './password-reset.dto';
diff --git a/libs/nestjs/password/src/dtos/password-reset-requested.dto.ts b/libs/nestjs/reset-password/src/dtos/password-reset-requested.dto.ts
similarity index 80%
rename from libs/nestjs/password/src/dtos/password-reset-requested.dto.ts
rename to libs/nestjs/reset-password/src/dtos/password-reset-requested.dto.ts
index cef9b4fc9..e952d655c 100644
--- a/libs/nestjs/password/src/dtos/password-reset-requested.dto.ts
+++ b/libs/nestjs/reset-password/src/dtos/password-reset-requested.dto.ts
@@ -2,5 +2,5 @@ import { IsString } from 'class-validator';
export class PasswordResetRequestedDto {
@IsString()
- login!: string;
+ id!: number | string;
}
diff --git a/libs/nestjs/password/src/dtos/password-reset.dto.ts b/libs/nestjs/reset-password/src/dtos/password-reset.dto.ts
similarity index 87%
rename from libs/nestjs/password/src/dtos/password-reset.dto.ts
rename to libs/nestjs/reset-password/src/dtos/password-reset.dto.ts
index 24b4d744c..cd918bf7f 100644
--- a/libs/nestjs/password/src/dtos/password-reset.dto.ts
+++ b/libs/nestjs/reset-password/src/dtos/password-reset.dto.ts
@@ -2,7 +2,7 @@ import { IsString } from 'class-validator';
export class PasswordResetDto {
@IsString()
- id!: string;
+ id!: string | number;
@IsString()
code!: string;
diff --git a/libs/nestjs/password/src/errors/bad-reset-code.error.spec.ts b/libs/nestjs/reset-password/src/errors/bad-reset-code.error.spec.ts
similarity index 100%
rename from libs/nestjs/password/src/errors/bad-reset-code.error.spec.ts
rename to libs/nestjs/reset-password/src/errors/bad-reset-code.error.spec.ts
diff --git a/libs/nestjs/password/src/errors/bad-reset-code.error.ts b/libs/nestjs/reset-password/src/errors/bad-reset-code.error.ts
similarity index 100%
rename from libs/nestjs/password/src/errors/bad-reset-code.error.ts
rename to libs/nestjs/reset-password/src/errors/bad-reset-code.error.ts
diff --git a/libs/nestjs/reset-password/src/errors/index.ts b/libs/nestjs/reset-password/src/errors/index.ts
new file mode 100644
index 000000000..a6f77bd24
--- /dev/null
+++ b/libs/nestjs/reset-password/src/errors/index.ts
@@ -0,0 +1 @@
+export * from './bad-reset-code.error';
diff --git a/libs/nestjs/reset-password/src/index.ts b/libs/nestjs/reset-password/src/index.ts
new file mode 100644
index 000000000..261fdc334
--- /dev/null
+++ b/libs/nestjs/reset-password/src/index.ts
@@ -0,0 +1,8 @@
+export * from './constants';
+export * from './controllers';
+export * from './dtos';
+export * from './errors';
+export * from './interfaces';
+export * from './services';
+export * from './reset-password.module';
+export * from './reset-password.module-definition';
diff --git a/libs/nestjs/reset-password/src/interfaces/index.ts b/libs/nestjs/reset-password/src/interfaces/index.ts
new file mode 100644
index 000000000..998bed155
--- /dev/null
+++ b/libs/nestjs/reset-password/src/interfaces/index.ts
@@ -0,0 +1 @@
+export * from './reset-password-module-options.interface';
diff --git a/libs/nestjs/reset-password/src/interfaces/reset-password-module-options.interface.ts b/libs/nestjs/reset-password/src/interfaces/reset-password-module-options.interface.ts
new file mode 100644
index 000000000..aa4185052
--- /dev/null
+++ b/libs/nestjs/reset-password/src/interfaces/reset-password-module-options.interface.ts
@@ -0,0 +1,58 @@
+import { JwtModuleOptions } from '@nestjs/jwt';
+
+import { SendEmailParams } from '@trxn/nestjs-mailer';
+import { MinimalUser } from '@trxn/nestjs-user';
+
+export type LinkFactory =
+ | ((
+ request: Record,
+ resetCode: string,
+ user: U,
+ ) => Promise | string)
+ | string;
+
+export type UserSecretFactory = (
+ request: Record