Skip to content
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

Merged
merged 13 commits into from Jul 11, 2023
Merged

Conversation

BiswaViraj
Copy link
Contributor

@BiswaViraj BiswaViraj commented Jul 7, 2023

What change does this PR introduce?

This is the base branch for the new workflows controller.

Note: All the stacked PRs have been merged here, so most probably it doesn't need much of a review as each stacked PR was reviewed.

Why was this change needed?

Other information (Screenshots)

Stacked PRs merged into this base branch:

@linear
Copy link

linear bot commented Jul 7, 2023

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 0.16.0 version.

Definition of Done

  • A new workflows controller with all existing templates functionality is available
  • All existing tests are working against it
  • Old templates controller and methods are marked as "Deprecated"
  • A deprecation label is visible on our API reference documentation.

@github-actions
Copy link

github-actions bot commented Jul 7, 2023

Pull reviewers stats

Stats of the last 30 days for novu:

User Total reviews Time to review Total comments
p-fernandez 60 18h 28m 168
LetItRock 21 1d 8h 3m 75
djabarovgeorge 15 2d 9h 51m 53
scopsy 13 47m 3
unicodeveloper 12 7d 8h 42m 123
ainouzgali 12 9h 25m 47
jainpawan21 5 3h 16m 2
davidsoderberg 4 16h 18m 2
BiswaViraj 4 1d 22h 30m 2
peoray 1 27m 1
michaldziuba03 1 10h 53m 1
Cliftonz 1 12h 3m 3

Copy link
Contributor

@p-fernandez p-fernandez left a 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! 🌟

import { PreferenceChannels } from '../../shared/dtos/preference-channels';
import { NotificationStep } from '../../shared/dtos/notification-step';

export class CreateWorkflowRequestDto implements ICreateNotificationTemplateDto {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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/index.ts Outdated Show resolved Hide resolved
@@ -0,0 +1,32 @@
import { expect } from 'chai';
import { NotificationTemplateService, UserSession } from '@novu/testing';
Copy link
Contributor

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.

Copy link
Contributor

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. 🙏🏻

apps/api/src/app/workflows/workflows.controller.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@ainouzgali ainouzgali left a 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 ',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
message: 'Notification group must be provided ',
message: 'Workflow group must be provided ',

We are also changing notification group => workflow group

Copy link
Contributor Author

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?

Copy link
Contributor

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


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`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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`);

command.environmentId
);
if (!notificationTemplateWithStepTemplate) {
throw new NotFoundException(`Notification template ${command.id} is not found`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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')
Copy link
Contributor

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

Copy link
Contributor Author

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

@BiswaViraj BiswaViraj added this pull request to the merge queue Jul 11, 2023
Merged via the queue into next with commit 5bbd72a Jul 11, 2023
30 checks passed
@BiswaViraj BiswaViraj deleted the nv-2405-workflows-crud-controller branch July 11, 2023 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants