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

fix(api-service): Nv 5293 sdk cleanup pre release #7616

Merged
merged 22 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions apps/api/e2e/retry.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ describe('Novu Node.js package - Retries and idempotency-key', () => {
serverURL: BACKEND_URL,
httpClient,
});
await novuClient.trigger({ name: 'fake-workflow', to: { subscriberId: '123' }, payload: {} });
await novuClient.trigger({ name: 'fake-workflow', to: { subscriberId: '123' }, payload: {} });
await novuClient.trigger({ workflowId: 'fake-workflow', to: { subscriberId: '123' }, payload: {} });
await novuClient.trigger({ workflowId: 'fake-workflow', to: { subscriberId: '123' }, payload: {} });

const idempotencyRequestKeys = getIdempotencyRequestKeys(httpClient);
expect(new Set(idempotencyRequestKeys).size, JSON.stringify(idempotencyRequestKeys)).to.be.eq(2);
Expand Down Expand Up @@ -104,7 +104,7 @@ describe('Novu Node.js package - Retries and idempotency-key', () => {
httpClient: mockHTTPClient,
});

await novuClient.trigger({ name: 'fake-workflow', to: { subscriberId: '123' }, payload: {} });
await novuClient.trigger({ workflowId: 'fake-workflow', to: { subscriberId: '123' }, payload: {} });
expect(mockHTTPClient.getRecordedRequests().length).to.eq(4);
const idempotencyKeys = getIdempotencyKeys(mockHTTPClient);
expect(hasUniqueOnly(idempotencyKeys)).to.be.eq(true);
Expand Down
26 changes: 12 additions & 14 deletions apps/api/src/app/events/dtos/trigger-event-request.dto.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { IsDefined, IsObject, IsOptional, IsString, ValidateIf, ValidateNested } from 'class-validator';
import { Type } from 'class-transformer';
import { ApiExtraModels, ApiProperty, ApiPropertyOptional, getSchemaPath } from '@nestjs/swagger';
import { ApiExtraModels, ApiHideProperty, ApiProperty, ApiPropertyOptional, getSchemaPath } from '@nestjs/swagger';
import {
TriggerRecipientsPayload,
TriggerRecipientsTypeEnum,
Expand All @@ -9,6 +9,7 @@ import {
} from '@novu/shared';
import { CreateSubscriberRequestDto } from '../../subscribers/dtos';
import { UpdateTenantRequestDto } from '../../tenant/dtos';
import { SdkApiProperty } from '../../shared/framework/swagger/sdk.decorators';

export class WorkflowToStepControlValuesDto {
/**
Expand Down Expand Up @@ -46,11 +47,14 @@ export class TopicPayloadDto {

@ApiExtraModels(SubscriberPayloadDto, TenantPayloadDto, TopicPayloadDto)
export class TriggerEventRequestDto {
@ApiProperty({
description:
'The trigger identifier of the workflow you wish to send. This identifier can be found on the workflow page.',
example: 'workflow_identifier',
})
@SdkApiProperty(
{
description:
'The trigger identifier of the workflow you wish to send. This identifier can be found on the workflow page.',
example: 'workflow_identifier',
},
{ nameOverride: 'workflowId' }
)
@IsString()
@IsDefined()
name: string;
Expand All @@ -73,10 +77,7 @@ export class TriggerEventRequestDto {
@IsOptional()
payload?: Record<string, unknown>;

@ApiPropertyOptional({
description: 'A URL to bridge for additional processing.',
example: 'https://example.com/bridge',
})
@ApiHideProperty()
@IsString()
@IsOptional()
bridgeUrl?: string;
Expand Down Expand Up @@ -175,10 +176,7 @@ export class TriggerEventRequestDto {
@Type(() => TenantPayloadDto)
tenant?: TriggerTenantContext;

@ApiPropertyOptional({
description: 'Additional control configurations.',
type: WorkflowToStepControlValuesDto,
})
@ApiHideProperty()
controls?: WorkflowToStepControlValuesDto;
}

Expand Down
18 changes: 9 additions & 9 deletions apps/api/src/app/events/e2e/bulk-trigger.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe('Trigger bulk events - /v1/events/trigger/bulk (POST) #novu-v2', functi
events: [
{
transactionId: '1111',
name: template.triggers[0].identifier,
workflowId: template.triggers[0].identifier,
to: [subscriber.subscriberId],
payload: {
firstName: 'Testing of User Name',
Expand All @@ -58,7 +58,7 @@ describe('Trigger bulk events - /v1/events/trigger/bulk (POST) #novu-v2', functi
},
{
transactionId: '2222',
name: template.triggers[0].identifier,
workflowId: template.triggers[0].identifier,
to: [subscriber.subscriberId],
payload: {
firstName: 'Testing of User Name',
Expand All @@ -67,7 +67,7 @@ describe('Trigger bulk events - /v1/events/trigger/bulk (POST) #novu-v2', functi
},
{
transactionId: '3333',
name: template.triggers[0].identifier,
workflowId: template.triggers[0].identifier,
to: [subscriber.subscriberId],
payload: {
firstName: 'Testing of User Name',
Expand Down Expand Up @@ -103,7 +103,7 @@ describe('Trigger bulk events - /v1/events/trigger/bulk (POST) #novu-v2', functi
await novuClient.triggerBulk({
events: [
{
name: template.triggers[0].identifier,
workflowId: template.triggers[0].identifier,
to: [
{
subscriberId: subscriber.subscriberId,
Expand All @@ -115,7 +115,7 @@ describe('Trigger bulk events - /v1/events/trigger/bulk (POST) #novu-v2', functi
},
},
{
name: secondTemplate.triggers[0].identifier,
workflowId: secondTemplate.triggers[0].identifier,
to: [
{
subscriberId: secondSubscriber.subscriberId,
Expand Down Expand Up @@ -202,7 +202,7 @@ describe('Trigger bulk events - /v1/events/trigger/bulk (POST) #novu-v2', functi
it('should throw an error when sending more than 100 events', async function () {
const event: TriggerEventRequestDto = {
transactionId: '2222',
name: template.triggers[0].identifier,
workflowId: template.triggers[0].identifier,
to: [subscriber.subscriberId],
payload: {
firstName: 'Testing of User Name',
Expand All @@ -225,7 +225,7 @@ describe('Trigger bulk events - /v1/events/trigger/bulk (POST) #novu-v2', functi
events: [
{
transactionId: '1111',
name: 'non-existing-trigger',
workflowId: 'non-existing-trigger',
to: [subscriber.subscriberId],
payload: {
firstName: 'Testing of User Name',
Expand All @@ -234,7 +234,7 @@ describe('Trigger bulk events - /v1/events/trigger/bulk (POST) #novu-v2', functi
},
{
transactionId: '2222',
name: template.triggers[0].identifier,
workflowId: template.triggers[0].identifier,
to: [subscriber.subscriberId],
payload: {
firstName: 'Testing of User Name',
Expand All @@ -247,7 +247,7 @@ describe('Trigger bulk events - /v1/events/trigger/bulk (POST) #novu-v2', functi
firstName: 'Testing of User Name',
name: '',
},
name: '',
workflowId: '',
to: [],
},
],
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/app/events/e2e/cancel-event.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('Cancel event - /v1/events/trigger/:transactionId (DELETE) #novu-v2', f
return (
await novuClient.trigger({
transactionId,
name: template.triggers[0].identifier,
workflowId: template.triggers[0].identifier,
to,
payload,
overrides,
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/app/events/e2e/send-message-push.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ describe('Trigger event - Send Push Notification - /v1/events/trigger (POST) #no
});
async function triggerEvent(template2) {
await novuClient.trigger({
name: template2.triggers[0].identifier,
workflowId: template2.triggers[0].identifier,
to: [{ subscriberId: session.subscriberId }],
payload: {},
});
Expand Down
4 changes: 2 additions & 2 deletions apps/api/src/app/events/e2e/trigger-event-topic.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ const buildTriggerRequestPayload = (
attachments?: Record<string, unknown>[]
): TriggerEventRequestDto => {
return {
name: template.triggers[0].identifier,
workflowId: template.triggers[0].identifier,
to,
payload: {
firstName: 'Testing of User Name',
Expand All @@ -547,7 +547,7 @@ const triggerEvent = async (
payload: Record<string, unknown> = {}
): Promise<void> => {
await initNovuClassSdk(session).trigger({
name: template.triggers[0].identifier,
workflowId: template.triggers[0].identifier,
to,
payload,
});
Expand Down
Loading
Loading