New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nv 2405 workflows crud controller #3745
Conversation
…nd commands as deprecated
NV-2405 Workflows CRUD Controller
What?Reusing the current "templates" usecases created a "workflows" controller that will have the exact same functionality of the existing one. Why? (Context)To finalize our "workflows" terminology migration from Definition of Done
|
Pull reviewers statsStats of the last 30 days for novu:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I missed some filenames mainly. 🙏🏻
I leave it approved anyway so you can merge it whenever.
Many thanks for doing this tedious work! 🌟
apps/api/src/app/workflows/dto/change-template-status-request.dto.ts
Outdated
Show resolved
Hide resolved
apps/api/src/app/workflows/dto/create-notification-template.request.dto.ts
Outdated
Show resolved
Hide resolved
import { PreferenceChannels } from '../../shared/dtos/preference-channels'; | ||
import { NotificationStep } from '../../shared/dtos/notification-step'; | ||
|
||
export class CreateWorkflowRequestDto implements ICreateNotificationTemplateDto { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export class CreateWorkflowRequestDto implements ICreateNotificationTemplateDto { | |
export class CreateWorkflowRequestDto implements ICreateWorkflowDto { |
We would need to rename the implemented interface. You might need to duplicate it to not affect the deprecated API or just change the implemented DTO also for the deprecated API.
apps/api/src/app/workflows/dto/create-notification-template.request.dto.ts
Outdated
Show resolved
Hide resolved
apps/api/src/app/workflows/dto/update-notification-template-request.dto.ts
Outdated
Show resolved
Hide resolved
@@ -0,0 +1,32 @@ | |||
import { expect } from 'chai'; | |||
import { NotificationTemplateService, UserSession } from '@novu/testing'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not for this one but might need to change the DAL service name too in the near future for consistency. Unfortunately schema will might have to remain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename to workflow is needed. 🙏🏻
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job @BiswaViraj ! Just notice the file names changes Pablo pointed out.
@ApiProperty() | ||
@IsString() | ||
@IsDefined({ | ||
message: 'Notification group must be provided ', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
message: 'Notification group must be provided ', | |
message: 'Workflow group must be provided ', |
We are also changing notification group => workflow group
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ainouzgali Should we also create a new controller for it with usecases renamed to the new one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should, so we have all outside refactor together. But maybe in a separate pr would feel more tidy
...pp/workflows/usecases/change-workflow-active-status/change-workflow-active-status.usecase.ts
Outdated
Show resolved
Hide resolved
...pp/workflows/usecases/change-workflow-active-status/change-workflow-active-status.usecase.ts
Outdated
Show resolved
Hide resolved
apps/api/src/app/workflows/usecases/create-workflow/create-workflow.usecase.ts
Outdated
Show resolved
Hide resolved
|
||
async execute(command: UpdateWorkflowCommand): Promise<NotificationTemplateEntity> { | ||
const existingTemplate = await this.notificationTemplateRepository.findById(command.id, command.environmentId); | ||
if (!existingTemplate) throw new NotFoundException(`Notification template with id ${command.id} not found`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (!existingTemplate) throw new NotFoundException(`Notification template with id ${command.id} not found`); | |
if (!existingTemplate) throw new NotFoundException(`Workflow with id ${command.id} not found`); |
apps/api/src/app/workflows/usecases/update-workflow/update-workflow.usecase.ts
Outdated
Show resolved
Hide resolved
command.environmentId | ||
); | ||
if (!notificationTemplateWithStepTemplate) { | ||
throw new NotFoundException(`Notification template ${command.id} is not found`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
throw new NotFoundException(`Notification template ${command.id} is not found`); | |
throw new NotFoundException(`Workflow with id ${command.id} not found`); |
@@ -43,7 +43,7 @@ import { CreateNotificationTemplateQuery } from './queries'; | |||
@Controller('/notification-templates') | |||
@UseInterceptors(ClassSerializerInterceptor) | |||
@UseGuards(JwtAuthGuard) | |||
@ApiTags('Workflows') | |||
@ApiTags('Notification Templates') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to still show it in our api docs? Because 'Notification Templates' tag should be added to bootstrap. It currently shows Workflows
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can show it for a few releases and then remove it later
refactor: rename dtos to workflow, and other minor changes
What change does this PR introduce?
This is the base branch for the new workflows controller.
Why was this change needed?
Other information (Screenshots)
Stacked PRs merged into this base branch: