-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(root): Release 2024-10-18 08:05 (#6719)
- Loading branch information
Showing
88 changed files
with
1,551 additions
and
513 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 9 additions & 0 deletions
9
apps/api/src/app/environments-v2/dtos/get-environment-tags.dto.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
import { IsDefined, IsString } from 'class-validator'; | ||
|
||
export class GetEnvironmentTagsDto { | ||
@ApiProperty() | ||
@IsDefined() | ||
@IsString() | ||
name: string; | ||
} |
34 changes: 34 additions & 0 deletions
34
apps/api/src/app/environments-v2/environments.controller.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { ClassSerializerInterceptor, Controller, Get, Param, UseInterceptors } from '@nestjs/common'; | ||
import { UserSessionData } from '@novu/shared'; | ||
import { ApiTags } from '@nestjs/swagger'; | ||
import { UserSession } from '../shared/framework/user.decorator'; | ||
import { GetEnvironmentTags, GetEnvironmentTagsCommand } from './usecases/get-environment-tags'; | ||
import { ExternalApiAccessible } from '../auth/framework/external-api.decorator'; | ||
import { ApiCommonResponses, ApiResponse } from '../shared/framework/response.decorator'; | ||
import { UserAuthentication } from '../shared/framework/swagger/api.key.security'; | ||
import { GetEnvironmentTagsDto } from './dtos/get-environment-tags.dto'; | ||
|
||
@ApiCommonResponses() | ||
@Controller({ path: `/environments`, version: '2' }) | ||
@UseInterceptors(ClassSerializerInterceptor) | ||
@UserAuthentication() | ||
@ApiTags('Environments') | ||
export class EnvironmentsController { | ||
constructor(private getEnvironmentTagsUsecase: GetEnvironmentTags) {} | ||
|
||
@Get('/:environmentId/tags') | ||
@ApiResponse(GetEnvironmentTagsDto) | ||
@ExternalApiAccessible() | ||
async getEnvironmentTags( | ||
@UserSession() user: UserSessionData, | ||
@Param('environmentId') environmentId: string | ||
): Promise<GetEnvironmentTagsDto[]> { | ||
return await this.getEnvironmentTagsUsecase.execute( | ||
GetEnvironmentTagsCommand.create({ | ||
environmentId, | ||
userId: user._id, | ||
organizationId: user.organizationId, | ||
}) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { EnvironmentsController } from './environments.controller'; | ||
import { GetEnvironmentTags } from './usecases/get-environment-tags'; | ||
import { SharedModule } from '../shared/shared.module'; | ||
|
||
@Module({ | ||
imports: [SharedModule], | ||
controllers: [EnvironmentsController], | ||
providers: [GetEnvironmentTags], | ||
exports: [], | ||
}) | ||
export class EnvironmentsModule {} |
3 changes: 3 additions & 0 deletions
3
...api/src/app/environments-v2/usecases/get-environment-tags/get-environment-tags.command.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { EnvironmentWithUserCommand } from '../../../shared/commands/project.command'; | ||
|
||
export class GetEnvironmentTagsCommand extends EnvironmentWithUserCommand {} |
53 changes: 53 additions & 0 deletions
53
apps/api/src/app/environments-v2/usecases/get-environment-tags/get-environment-tags.e2e.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { EnvironmentRepository, NotificationTemplateRepository } from '@novu/dal'; | ||
import { UserSession } from '@novu/testing'; | ||
import { expect } from 'chai'; | ||
|
||
describe('Get Environment Tags - /v2/environments/:environmentId/tags (GET)', async () => { | ||
let session: UserSession; | ||
const environmentRepository = new EnvironmentRepository(); | ||
const notificationTemplateRepository = new NotificationTemplateRepository(); | ||
|
||
before(async () => { | ||
session = new UserSession(); | ||
await session.initialize(); | ||
}); | ||
|
||
it('should return correct tags for the environment', async () => { | ||
await notificationTemplateRepository.create({ | ||
_environmentId: session.environment._id, | ||
tags: ['tag1', 'tag2'], | ||
}); | ||
await notificationTemplateRepository.create({ | ||
_environmentId: session.environment._id, | ||
tags: ['tag2', 'tag3', null, '', undefined], | ||
}); | ||
|
||
const { body } = await session.testAgent.get(`/v2/environments/${session.environment._id}/tags`); | ||
|
||
expect(body.data).to.be.an('array'); | ||
expect(body.data).to.have.lengthOf(3); | ||
expect(body.data).to.deep.include({ name: 'tag1' }); | ||
expect(body.data).to.deep.include({ name: 'tag2' }); | ||
expect(body.data).to.deep.include({ name: 'tag3' }); | ||
}); | ||
|
||
it('should return an empty array when no tags exist', async () => { | ||
const newEnvironment = await environmentRepository.create({ | ||
name: 'Test Environment', | ||
_organizationId: session.organization._id, | ||
}); | ||
|
||
const { body } = await session.testAgent.get(`/v2/environments/${newEnvironment._id}/tags`); | ||
|
||
expect(body.data).to.be.an('array'); | ||
expect(body.data).to.have.lengthOf(0); | ||
}); | ||
|
||
it('should throw NotFoundException for non-existent environment', async () => { | ||
const nonExistentId = '60a5f2f2f2f2f2f2f2f2f2f2'; | ||
const { body } = await session.testAgent.get(`/v2/environments/${nonExistentId}/tags`); | ||
|
||
expect(body.statusCode).to.equal(404); | ||
expect(body.message).to.equal(`Environment ${nonExistentId} not found`); | ||
}); | ||
}); |
Oops, something went wrong.