diff --git a/apps/api/e2e/retry.e2e.ts b/apps/api/e2e/retry.e2e.ts index 3ac3293bad3..0212288013a 100644 --- a/apps/api/e2e/retry.e2e.ts +++ b/apps/api/e2e/retry.e2e.ts @@ -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); @@ -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); diff --git a/apps/api/src/app/events/dtos/trigger-event-request.dto.ts b/apps/api/src/app/events/dtos/trigger-event-request.dto.ts index eb6f743ed3f..a37ddc5e32a 100644 --- a/apps/api/src/app/events/dtos/trigger-event-request.dto.ts +++ b/apps/api/src/app/events/dtos/trigger-event-request.dto.ts @@ -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, @@ -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 { /** @@ -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; @@ -73,10 +77,7 @@ export class TriggerEventRequestDto { @IsOptional() payload?: Record; - @ApiPropertyOptional({ - description: 'A URL to bridge for additional processing.', - example: 'https://example.com/bridge', - }) + @ApiHideProperty() @IsString() @IsOptional() bridgeUrl?: string; @@ -175,10 +176,7 @@ export class TriggerEventRequestDto { @Type(() => TenantPayloadDto) tenant?: TriggerTenantContext; - @ApiPropertyOptional({ - description: 'Additional control configurations.', - type: WorkflowToStepControlValuesDto, - }) + @ApiHideProperty() controls?: WorkflowToStepControlValuesDto; } diff --git a/apps/api/src/app/events/e2e/bulk-trigger.e2e.ts b/apps/api/src/app/events/e2e/bulk-trigger.e2e.ts index 55cb5b67572..37620e8e584 100644 --- a/apps/api/src/app/events/e2e/bulk-trigger.e2e.ts +++ b/apps/api/src/app/events/e2e/bulk-trigger.e2e.ts @@ -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', @@ -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', @@ -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', @@ -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, @@ -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, @@ -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', @@ -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', @@ -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', @@ -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: [], }, ], diff --git a/apps/api/src/app/events/e2e/cancel-event.e2e.ts b/apps/api/src/app/events/e2e/cancel-event.e2e.ts index a4046a3bd43..7cc50475be9 100644 --- a/apps/api/src/app/events/e2e/cancel-event.e2e.ts +++ b/apps/api/src/app/events/e2e/cancel-event.e2e.ts @@ -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, diff --git a/apps/api/src/app/events/e2e/send-message-push.e2e.ts b/apps/api/src/app/events/e2e/send-message-push.e2e.ts index 83fcbafeda5..98dfe483cc1 100644 --- a/apps/api/src/app/events/e2e/send-message-push.e2e.ts +++ b/apps/api/src/app/events/e2e/send-message-push.e2e.ts @@ -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: {}, }); diff --git a/apps/api/src/app/events/e2e/trigger-event-topic.e2e.ts b/apps/api/src/app/events/e2e/trigger-event-topic.e2e.ts index 07a6f973dea..b09fa2cc388 100644 --- a/apps/api/src/app/events/e2e/trigger-event-topic.e2e.ts +++ b/apps/api/src/app/events/e2e/trigger-event-topic.e2e.ts @@ -530,7 +530,7 @@ const buildTriggerRequestPayload = ( attachments?: Record[] ): TriggerEventRequestDto => { return { - name: template.triggers[0].identifier, + workflowId: template.triggers[0].identifier, to, payload: { firstName: 'Testing of User Name', @@ -547,7 +547,7 @@ const triggerEvent = async ( payload: Record = {} ): Promise => { await initNovuClassSdk(session).trigger({ - name: template.triggers[0].identifier, + workflowId: template.triggers[0].identifier, to, payload, }); diff --git a/apps/api/src/app/events/e2e/trigger-event.e2e.ts b/apps/api/src/app/events/e2e/trigger-event.e2e.ts index 0501025e2a7..bff45f67d8f 100644 --- a/apps/api/src/app/events/e2e/trigger-event.e2e.ts +++ b/apps/api/src/app/events/e2e/trigger-event.e2e.ts @@ -19,10 +19,12 @@ import { ActorTypeEnum, ChannelTypeEnum, ChatProviderIdEnum, + CreateWorkflowDto, DelayTypeEnum, DigestUnitEnum, EmailBlockTypeEnum, EmailProviderIdEnum, + ExecutionDetailsStatusEnum, FieldLogicalOperatorEnum, FieldOperatorEnum, FilterPartTypeEnum, @@ -33,10 +35,8 @@ import { StepTypeEnum, SystemAvatarIconEnum, TemplateVariableTypeEnum, - CreateWorkflowDto, WorkflowCreationSourceEnum, WorkflowResponseDto, - ExecutionDetailsStatusEnum, } from '@novu/shared'; import { EmailEventStatusEnum } from '@novu/stateless'; import { DetailEnum } from '@novu/application-generic'; @@ -127,7 +127,7 @@ describe('Trigger event - /v1/events/trigger (POST) #novu-v2', function () { }); await novuClient.trigger({ - name: template.triggers[0].identifier, + workflowId: template.triggers[0].identifier, to: [subscriber.subscriberId], payload: { customVar: 'Testing of User Name', @@ -191,7 +191,7 @@ describe('Trigger event - /v1/events/trigger (POST) #novu-v2', function () { }); await novuClient.trigger({ - name: template.triggers[0].identifier, + workflowId: template.triggers[0].identifier, to: [subscriber.subscriberId], payload: { customVar: 'Testing of User Name', @@ -263,7 +263,7 @@ describe('Trigger event - /v1/events/trigger (POST) #novu-v2', function () { }); await novuClient.trigger({ - name: template.triggers[0].identifier, + workflowId: template.triggers[0].identifier, to: [subscriber.subscriberId], payload: { customVar: 'Testing of User Name', @@ -383,7 +383,7 @@ describe('Trigger event - /v1/events/trigger (POST) #novu-v2', function () { }); await novuClient.trigger({ - name: template.triggers[0].identifier, + workflowId: template.triggers[0].identifier, to: [subscriber.subscriberId], payload: { customVar: 'Testing of User Name', @@ -457,7 +457,7 @@ describe('Trigger event - /v1/events/trigger (POST) #novu-v2', function () { }); await novuClient.trigger({ - name: template.triggers[0].identifier, + workflowId: template.triggers[0].identifier, to: [subscriber.subscriberId], payload: { customVar: 'Testing of User Name', @@ -520,14 +520,14 @@ describe('Trigger event - /v1/events/trigger (POST) #novu-v2', function () { }); await novuClient.trigger({ - name: template.triggers[0].identifier, + workflowId: template.triggers[0].identifier, to: [subscriber.subscriberId], payload: { exclude: false, }, }); await novuClient.trigger({ - name: template.triggers[0].identifier, + workflowId: template.triggers[0].identifier, to: [subscriber.subscriberId], payload: { exclude: false, @@ -591,14 +591,14 @@ describe('Trigger event - /v1/events/trigger (POST) #novu-v2', function () { }); await novuClient.trigger({ - name: template.triggers[0].identifier, + workflowId: template.triggers[0].identifier, to: [subscriber.subscriberId], payload: { exclude: false, }, }); await novuClient.trigger({ - name: template.triggers[0].identifier, + workflowId: template.triggers[0].identifier, to: [subscriber.subscriberId], payload: {}, }); @@ -670,7 +670,7 @@ describe('Trigger event - /v1/events/trigger (POST) #novu-v2', function () { }); await novuClient.trigger({ - name: template.triggers[0].identifier, + workflowId: template.triggers[0].identifier, to: [subscriber.subscriberId], payload: { customVar: 'Testing of User Name', @@ -823,7 +823,7 @@ describe('Trigger event - /v1/events/trigger (POST) #novu-v2', function () { it('should trigger an event successfully', async function () { const response = await novuClient.trigger({ - name: template.triggers[0].identifier, + workflowId: template.triggers[0].identifier, to: [subscriber.subscriberId], payload: { firstName: 'Testing of User Name', @@ -840,7 +840,7 @@ describe('Trigger event - /v1/events/trigger (POST) #novu-v2', function () { it('should store jobs & message provider id successfully', async function () { await novuClient.trigger({ - name: template.triggers[0].identifier, + workflowId: template.triggers[0].identifier, to: [subscriber.subscriberId], }); @@ -882,7 +882,7 @@ describe('Trigger event - /v1/events/trigger (POST) #novu-v2', function () { data: { custom1: 'custom value1', custom2: 'custom value2' }, }; await novuClient.trigger({ - name: template.triggers[0].identifier, + workflowId: template.triggers[0].identifier, to: [payload], payload: { urlVar: '/test/url/path', @@ -912,7 +912,7 @@ describe('Trigger event - /v1/events/trigger (POST) #novu-v2', function () { }; await novuClient.trigger({ - name: template.triggers[0].identifier, + workflowId: template.triggers[0].identifier, to: [ { ...payload, @@ -933,7 +933,7 @@ describe('Trigger event - /v1/events/trigger (POST) #novu-v2', function () { expect(createdSubscriber?.locale).to.equal(payload.locale); await novuClient.trigger({ - name: template.triggers[0].identifier, + workflowId: template.triggers[0].identifier, to: [ { ...payload, @@ -976,7 +976,7 @@ describe('Trigger event - /v1/events/trigger (POST) #novu-v2', function () { }; await novuClient.trigger({ - name: template.triggers[0].identifier, + workflowId: template.triggers[0].identifier, to: [payload], payload: { urlVar: '/test/url/path', @@ -1025,7 +1025,7 @@ describe('Trigger event - /v1/events/trigger (POST) #novu-v2', function () { }; await novuClient.trigger({ - name: template.triggers[0].identifier, + workflowId: template.triggers[0].identifier, to: [ { ...payload, @@ -1043,7 +1043,7 @@ describe('Trigger event - /v1/events/trigger (POST) #novu-v2', function () { expect(createdSubscriber?.channels?.length).to.equal(1); await novuClient.trigger({ - name: template.triggers[0].identifier, + workflowId: template.triggers[0].identifier, to: [ { ...payload, @@ -1086,7 +1086,7 @@ describe('Trigger event - /v1/events/trigger (POST) #novu-v2', function () { }; await novuClient.trigger({ - name: template.triggers[0].identifier, + workflowId: template.triggers[0].identifier, to: [ { ...payload, @@ -1107,7 +1107,7 @@ describe('Trigger event - /v1/events/trigger (POST) #novu-v2', function () { expect(createdSubscriber?.locale).to.equal(payload.locale); await novuClient.trigger({ - name: template.triggers[0].identifier, + workflowId: template.triggers[0].identifier, to: [ { ...payload, @@ -1135,7 +1135,7 @@ describe('Trigger event - /v1/events/trigger (POST) #novu-v2', function () { const transactionId = SubscriberRepository.createObjectId(); await novuClient.trigger({ - name: template.triggers[0].identifier, + workflowId: template.triggers[0].identifier, transactionId, to: [ { subscriberId: subscriber.subscriberId, email: 'gg@ff.com' }, @@ -1183,7 +1183,7 @@ describe('Trigger event - /v1/events/trigger (POST) #novu-v2', function () { it('should generate message and notification based on event', async function () { await novuClient.trigger({ - name: template.triggers[0].identifier, + workflowId: template.triggers[0].identifier, to: [ { subscriberId: subscriber.subscriberId, @@ -1250,7 +1250,7 @@ describe('Trigger event - /v1/events/trigger (POST) #novu-v2', function () { const templateName = template.triggers[0].identifier; const response = await novuClient.trigger({ - name: templateName, + workflowId: templateName, to: [ { subscriberId: subscriber.subscriberId, @@ -1313,7 +1313,7 @@ describe('Trigger event - /v1/events/trigger (POST) #novu-v2', function () { }); await novuClient.trigger({ - name: template.triggers[0].identifier, + workflowId: template.triggers[0].identifier, to: [subscriber.subscriberId], payload: { customVar: 'Testing of User Name', @@ -1344,7 +1344,7 @@ describe('Trigger event - /v1/events/trigger (POST) #novu-v2', function () { }); await novuClient.trigger({ - name: template.triggers[0].identifier, + workflowId: template.triggers[0].identifier, to: [{ subscriberId: subscriber.subscriberId }, { subscriberId, phone: '+972541111111' }], payload: { organizationName: 'Testing of Organization Name', @@ -1382,7 +1382,7 @@ describe('Trigger event - /v1/events/trigger (POST) #novu-v2', function () { ], }); await novuClient.trigger({ - name: template.triggers[0].identifier, + workflowId: template.triggers[0].identifier, to: [subscriber.subscriberId], payload: { phone: '+972541111111', @@ -1901,7 +1901,7 @@ describe('Trigger event - /v1/events/trigger (POST) #novu-v2', function () { }); const response = await novuClient.trigger({ - name: template.triggers[0].identifier, + workflowId: template.triggers[0].identifier, to: [subscriber.subscriberId], payload: { myUser: { @@ -1934,7 +1934,7 @@ describe('Trigger event - /v1/events/trigger (POST) #novu-v2', function () { }); await novuClient.trigger({ - name: template.triggers[0].identifier, + workflowId: template.triggers[0].identifier, to: [subscriber.subscriberId], payload: { myUser: { @@ -2060,7 +2060,7 @@ describe('Trigger event - /v1/events/trigger (POST) #novu-v2', function () { }); await novuClient.trigger({ - name: template.triggers[0].identifier, + workflowId: template.triggers[0].identifier, to: [subscriber.subscriberId], payload: { firstName: 'Testing of User Name', @@ -2125,7 +2125,7 @@ describe('Trigger event - /v1/events/trigger (POST) #novu-v2', function () { */ await novuClient.trigger({ - name: template.triggers[0].identifier, + workflowId: template.triggers[0].identifier, to: [subscriber.subscriberId], payload: {}, }); @@ -2149,7 +2149,7 @@ describe('Trigger event - /v1/events/trigger (POST) #novu-v2', function () { */ await novuClient.trigger({ - name: template.triggers[0].identifier, + workflowId: template.triggers[0].identifier, to: [subscriber.subscriberId], payload: {}, }); @@ -2205,7 +2205,7 @@ describe('Trigger event - /v1/events/trigger (POST) #novu-v2', function () { // const axiosPostStub = sinon.stub(axios, 'post').throws(new Error('Users remote error'))); await novuClient.trigger({ - name: template.triggers[0].identifier, + workflowId: template.triggers[0].identifier, to: [subscriber.subscriberId], payload: {}, }); @@ -2272,7 +2272,7 @@ describe('Trigger event - /v1/events/trigger (POST) #novu-v2', function () { */ await novuClient.trigger({ - name: template.triggers[0].identifier, + workflowId: template.triggers[0].identifier, to: [subscriber.subscriberId], payload: {}, }); @@ -2304,7 +2304,7 @@ describe('Trigger event - /v1/events/trigger (POST) #novu-v2', function () { */ await novuClient.trigger({ - name: template.triggers[0].identifier, + workflowId: template.triggers[0].identifier, to: [subscriber.subscriberId], payload: {}, }); @@ -2394,7 +2394,7 @@ describe('Trigger event - /v1/events/trigger (POST) #novu-v2', function () { }); await novuClient.trigger({ - name: templateWithVariants.triggers[0].identifier, + workflowId: templateWithVariants.triggers[0].identifier, to: [subscriber.subscriberId], payload: {}, tenant: { identifier: tenant.identifier }, @@ -2478,7 +2478,7 @@ describe('Trigger event - /v1/events/trigger (POST) #novu-v2', function () { }); await novuClient.trigger({ - name: template.triggers[0].identifier, + workflowId: template.triggers[0].identifier, to: [subscriber.subscriberId], payload: { firstName: 'Testing of User Name', @@ -2534,7 +2534,7 @@ describe('Trigger event - /v1/events/trigger (POST) #novu-v2', function () { }); await novuClient.trigger({ - name: template.triggers[0].identifier, + workflowId: template.triggers[0].identifier, to: [subscriber.subscriberId], payload: { firstName: 'Testing of User Name', @@ -2593,7 +2593,7 @@ describe('Trigger event - /v1/events/trigger (POST) #novu-v2', function () { }); await novuClient.trigger({ - name: templateWithVariants.triggers[0].identifier, + workflowId: templateWithVariants.triggers[0].identifier, to: [subscriber.subscriberId], payload: { count: 5 }, tenant: { identifier: tenant.identifier }, @@ -2609,7 +2609,7 @@ describe('Trigger event - /v1/events/trigger (POST) #novu-v2', function () { expect(messages.length).to.equal(0); await novuClient.trigger({ - name: templateWithVariants.triggers[0].identifier, + workflowId: templateWithVariants.triggers[0].identifier, to: [subscriber.subscriberId], payload: { count: 1 }, tenant: { identifier: tenant.identifier }, @@ -2698,7 +2698,7 @@ describe('Trigger event - /v1/events/trigger (POST) #novu-v2', function () { }); await novuClient.trigger({ - name: template.triggers[0].identifier, + workflowId: template.triggers[0].identifier, to: [subscriber.subscriberId], payload: {}, }); @@ -2736,7 +2736,7 @@ describe('Trigger event - /v1/events/trigger (POST) #novu-v2', function () { }); await novuClient.trigger({ - name: template.triggers[0].identifier, + workflowId: template.triggers[0].identifier, to: [subscriber.subscriberId], payload: {}, }); @@ -2776,7 +2776,7 @@ describe('Trigger event - /v1/events/trigger (POST) #novu-v2', function () { }); await novuClient.trigger({ - name: template.triggers[0].identifier, + workflowId: template.triggers[0].identifier, to: [subscriber.subscriberId], payload: {}, actor: actor.subscriberId, @@ -2839,7 +2839,7 @@ describe('Trigger event - /v1/events/trigger (POST) #novu-v2', function () { }); await novuClient.trigger({ - name: template.triggers[0].identifier, + workflowId: template.triggers[0].identifier, to: [subscriber.subscriberId], payload: { customVar: 'Testing of User Name', @@ -2923,7 +2923,7 @@ describe('Trigger event - /v1/events/trigger (POST) #novu-v2', function () { }); await novuClient.trigger({ - name: template.triggers[0].identifier, + workflowId: template.triggers[0].identifier, to: [subscriber.subscriberId], payload: { customVar: 'Testing of User Name', @@ -2993,7 +2993,7 @@ describe('Trigger event - /v1/events/trigger (POST) #novu-v2', function () { } const triggerResponse = await novuClient.trigger({ - name: workflow.triggers[0].identifier, + workflowId: workflow.triggers[0].identifier, to: [subscriberOverride], tenant: tenant.identifier, payload: { @@ -3020,7 +3020,7 @@ describe('Trigger event - /v1/events/trigger (POST) #novu-v2', function () { ); const triggerResponse2 = await novuClient.trigger({ - name: workflow.triggers[0].identifier, + workflowId: workflow.triggers[0].identifier, to: [subscriberOverride], tenant: tenant.identifier, payload: { @@ -3062,7 +3062,7 @@ describe('Trigger event - /v1/events/trigger (POST) #novu-v2', function () { } const triggerResponse = await novuClient.trigger({ - name: workflow.triggers[0].identifier, + workflowId: workflow.triggers[0].identifier, to: [subscriberOverride], tenant: tenant.identifier, payload: { @@ -3089,7 +3089,7 @@ describe('Trigger event - /v1/events/trigger (POST) #novu-v2', function () { ); const triggerResponse2 = await novuClient.trigger({ - name: workflow.triggers[0].identifier, + workflowId: workflow.triggers[0].identifier, to: [subscriberOverride], tenant: tenant.identifier, payload: { @@ -3131,7 +3131,7 @@ describe('Trigger event - /v1/events/trigger (POST) #novu-v2', function () { throw new Error('Tenant not found'); } const triggerResponse = await novuClient.trigger({ - name: workflow.triggers[0].identifier, + workflowId: workflow.triggers[0].identifier, to: [subscriberOverride], tenant: tenant.identifier, payload: { @@ -3182,7 +3182,7 @@ describe('Trigger event - /v1/events/trigger (POST) #novu-v2', function () { } const triggerResponse = await novuClient.trigger({ - name: workflow.triggers[0].identifier, + workflowId: workflow.triggers[0].identifier, to: [subscriberOverride], tenant: tenant.identifier, payload: { @@ -3216,7 +3216,7 @@ describe('Trigger event - /v1/events/trigger (POST) #novu-v2', function () { actor?: string ): Promise { const request = { - name: templateInner.triggers[0].identifier, + workflowId: templateInner.triggers[0].identifier, to: [{ subscriberId: newSubscriberIdInAppNotification, lastName: 'Smith', email: 'test@email.novu' }], payload: { organizationName: 'Umbrella Corp', @@ -3262,7 +3262,7 @@ describe('Trigger event - /v1/events/trigger (POST) #novu-v2', function () { const workflow: WorkflowResponseDto = response.body.data; await novuClient.trigger({ - name: workflow.workflowId, + workflowId: workflow.workflowId, to: [subscriber.subscriberId], payload: { shouldExecute: false, @@ -3276,7 +3276,7 @@ describe('Trigger event - /v1/events/trigger (POST) #novu-v2', function () { expect(skippedMessages.length).to.equal(0); await novuClient.trigger({ - name: workflow.workflowId, + workflowId: workflow.workflowId, to: [subscriber.subscriberId], payload: { shouldExecute: true, @@ -3324,7 +3324,7 @@ describe('Trigger event - /v1/events/trigger (POST) #novu-v2', function () { }); const triggerResponse = await novuClient.trigger({ - name: workflow.workflowId, + workflowId: workflow.workflowId, to: [subscriber.subscriberId], payload: { firstName: subscriber.firstName, @@ -3398,7 +3398,7 @@ describe('Trigger event - /v1/events/trigger (POST) #novu-v2', function () { }); await novuClient.trigger({ - name: workflow.workflowId, + workflowId: workflow.workflowId, to: [subscriber.subscriberId], payload: { userScore: 150, @@ -3419,7 +3419,7 @@ describe('Trigger event - /v1/events/trigger (POST) #novu-v2', function () { }); await novuClient.trigger({ - name: workflow.workflowId, + workflowId: workflow.workflowId, to: [subscriber.subscriberId], payload: { userScore: 150, @@ -3440,7 +3440,7 @@ describe('Trigger event - /v1/events/trigger (POST) #novu-v2', function () { }); await novuClient.trigger({ - name: workflow.workflowId, + workflowId: workflow.workflowId, to: [subscriber.subscriberId], payload: { userScore: 50, @@ -3482,7 +3482,7 @@ describe('Trigger event - /v1/events/trigger (POST) #novu-v2', function () { }); await novuClient.trigger({ - name: workflow.workflowId, + workflowId: workflow.workflowId, to: [subscriber.subscriberId], payload: { userScore: 150, diff --git a/apps/api/src/app/inbox/e2e/get-notifications-count.e2e.ts b/apps/api/src/app/inbox/e2e/get-notifications-count.e2e.ts index 75c87c764d0..28b0c220d1f 100644 --- a/apps/api/src/app/inbox/e2e/get-notifications-count.e2e.ts +++ b/apps/api/src/app/inbox/e2e/get-notifications-count.e2e.ts @@ -64,7 +64,7 @@ describe('Get Notifications Count - /inbox/notifications/count (GET) #novu-v2', for (let i = 0; i < times; i += 1) { promises.push( novuClient.trigger({ - name: templateToTrigger.triggers[0].identifier, + workflowId: templateToTrigger.triggers[0].identifier, to: { subscriberId: session.subscriberId }, }) ); diff --git a/apps/api/src/app/inbox/e2e/get-notifications.e2e.ts b/apps/api/src/app/inbox/e2e/get-notifications.e2e.ts index e27974dc08c..c5ffe6e4749 100644 --- a/apps/api/src/app/inbox/e2e/get-notifications.e2e.ts +++ b/apps/api/src/app/inbox/e2e/get-notifications.e2e.ts @@ -96,7 +96,7 @@ describe('Get Notifications - /inbox/notifications (GET) #novu-v2', async () => for (let i = 0; i < times; i += 1) { promises.push( novuClient.trigger({ - name: templateToTrigger.triggers[0].identifier, + workflowId: templateToTrigger.triggers[0].identifier, to: { subscriberId: session.subscriberId }, }) ); diff --git a/apps/api/src/app/inbox/e2e/mark-notification-as.e2e.ts b/apps/api/src/app/inbox/e2e/mark-notification-as.e2e.ts index ec3256e12ec..044bafd716a 100644 --- a/apps/api/src/app/inbox/e2e/mark-notification-as.e2e.ts +++ b/apps/api/src/app/inbox/e2e/mark-notification-as.e2e.ts @@ -46,7 +46,7 @@ describe('Mark Notification As - /inbox/notifications/:id/{read,unread,archive,u for (let i = 0; i < times; i += 1) { promises.push( novuClient.trigger({ - name: templateToTrigger.triggers[0].identifier, + workflowId: templateToTrigger.triggers[0].identifier, to: { subscriberId: session.subscriberId }, }) ); diff --git a/apps/api/src/app/inbox/e2e/update-all-notifications.e2e.ts b/apps/api/src/app/inbox/e2e/update-all-notifications.e2e.ts index 288b5ad24b3..2815b85ce28 100644 --- a/apps/api/src/app/inbox/e2e/update-all-notifications.e2e.ts +++ b/apps/api/src/app/inbox/e2e/update-all-notifications.e2e.ts @@ -37,7 +37,7 @@ describe('Update All Notifications - /inbox/notifications/{read,archive,read-arc for (let i = 0; i < times; i += 1) { promises.push( novuClient.trigger({ - name: templateToTrigger.triggers[0].identifier, + workflowId: templateToTrigger.triggers[0].identifier, to: { subscriberId: session.subscriberId }, }) ); diff --git a/apps/api/src/app/inbox/e2e/update-notification-action.e2e.ts b/apps/api/src/app/inbox/e2e/update-notification-action.e2e.ts index d1d6eac5c6f..aafe2624295 100644 --- a/apps/api/src/app/inbox/e2e/update-notification-action.e2e.ts +++ b/apps/api/src/app/inbox/e2e/update-notification-action.e2e.ts @@ -47,7 +47,7 @@ describe('Update Notification Action - /inbox/notifications/:id/{complete/revert for (let i = 0; i < times; i += 1) { promises.push( novuClient.trigger({ - name: templateToTrigger.triggers[0].identifier, + workflowId: templateToTrigger.triggers[0].identifier, to: { subscriberId: session.subscriberId }, }) ); diff --git a/apps/api/src/app/invites/usecases/accept-invite/accept-invite.usecase.ts b/apps/api/src/app/invites/usecases/accept-invite/accept-invite.usecase.ts index ae904578f7c..e836db80661 100644 --- a/apps/api/src/app/invites/usecases/accept-invite/accept-invite.usecase.ts +++ b/apps/api/src/app/invites/usecases/accept-invite/accept-invite.usecase.ts @@ -59,7 +59,7 @@ export class AcceptInvite { const novu = new Novu({ security: { secretKey: process.env.NOVU_API_KEY } }); await novu.trigger({ - name: process.env.NOVU_TEMPLATEID_INVITE_ACCEPTED || 'invite-accepted-dEQAsKD1E', + workflowId: process.env.NOVU_TEMPLATEID_INVITE_ACCEPTED || 'invite-accepted-dEQAsKD1E', to: [ { subscriberId: inviter._id, diff --git a/apps/api/src/app/invites/usecases/invite-member/invite-member.usecase.ts b/apps/api/src/app/invites/usecases/invite-member/invite-member.usecase.ts index e134cd8316e..7e1bd35d5c2 100644 --- a/apps/api/src/app/invites/usecases/invite-member/invite-member.usecase.ts +++ b/apps/api/src/app/invites/usecases/invite-member/invite-member.usecase.ts @@ -35,7 +35,7 @@ export class InviteMember { if (process.env.NOVU_API_KEY && (process.env.NODE_ENV === 'dev' || process.env.NODE_ENV === 'production')) { const novu = new Novu({ security: { secretKey: process.env.NOVU_API_KEY } }); await novu.trigger({ - name: process.env.NOVU_TEMPLATEID_INVITE_TO_ORGANISATION || 'invite-to-organization-wBnO8NpDn', + workflowId: process.env.NOVU_TEMPLATEID_INVITE_TO_ORGANISATION || 'invite-to-organization-wBnO8NpDn', to: [ { subscriberId: command.email, diff --git a/apps/api/src/app/invites/usecases/resend-invite/resend-invite.usecase.ts b/apps/api/src/app/invites/usecases/resend-invite/resend-invite.usecase.ts index bfcfdf3169f..15f5bef7b31 100644 --- a/apps/api/src/app/invites/usecases/resend-invite/resend-invite.usecase.ts +++ b/apps/api/src/app/invites/usecases/resend-invite/resend-invite.usecase.ts @@ -38,7 +38,7 @@ export class ResendInvite { // cspell:disable-next await novu.trigger({ - name: process.env.NOVU_TEMPLATEID_INVITE_TO_ORGANISATION || 'invite-to-organization-wBnO8NpDn', + workflowId: process.env.NOVU_TEMPLATEID_INVITE_TO_ORGANISATION || 'invite-to-organization-wBnO8NpDn', to: [ { subscriberId: foundInvitee.invite.email, diff --git a/apps/api/src/app/messages/e2e/get-messages.e2e.ts b/apps/api/src/app/messages/e2e/get-messages.e2e.ts index 14d74725aba..86d6ee67b82 100644 --- a/apps/api/src/app/messages/e2e/get-messages.e2e.ts +++ b/apps/api/src/app/messages/e2e/get-messages.e2e.ts @@ -23,7 +23,7 @@ describe('Get Message - /messages (GET) #novu-v2', function () { it('should fetch existing messages', async function () { const subscriber2 = await subscriberService.createSubscriber(); await novuClient.trigger({ - name: template.triggers[0].identifier, + workflowId: template.triggers[0].identifier, to: [ { subscriberId: subscriber.subscriberId, email: 'gg@ff.com' }, { subscriberId: subscriber2.subscriberId, email: 'john@doe.com' }, @@ -78,7 +78,7 @@ describe('Get Message - /messages (GET) #novu-v2', function () { transactionId: string ) { return await novuClient.trigger({ - name: templateIdentifier, + workflowId: templateIdentifier, to: [{ subscriberId, email: 'gg@ff.com' }], payload: {}, transactionId, diff --git a/apps/api/src/app/messages/e2e/remove-message.e2e.ts b/apps/api/src/app/messages/e2e/remove-message.e2e.ts index 495fda33c4d..fe478a35999 100644 --- a/apps/api/src/app/messages/e2e/remove-message.e2e.ts +++ b/apps/api/src/app/messages/e2e/remove-message.e2e.ts @@ -34,7 +34,7 @@ describe('Delete Message - /messages/:messageId (DELETE) #novu-v2', function () it('should delete a existing message', async function () { await novuClient.trigger({ - name: template.triggers[0].identifier, + workflowId: template.triggers[0].identifier, to: [{ subscriberId: subscriber.subscriberId, email: 'gg@ff.com' }], payload: { email: 'new-test-email@gmail.com', diff --git a/apps/api/src/app/notifications/e2e/get-activity-feed.e2e.ts b/apps/api/src/app/notifications/e2e/get-activity-feed.e2e.ts index 5f987497594..93ec6c0281c 100644 --- a/apps/api/src/app/notifications/e2e/get-activity-feed.e2e.ts +++ b/apps/api/src/app/notifications/e2e/get-activity-feed.e2e.ts @@ -34,13 +34,13 @@ describe('Get activity feed - /notifications (GET) #novu-v2', async () => { it('should get the current activity feed of user', async function () { await novuClient.trigger({ - name: template.triggers[0].identifier, + workflowId: template.triggers[0].identifier, to: subscriberId, payload: { firstName: 'Test' }, }); await novuClient.trigger({ - name: template.triggers[0].identifier, + workflowId: template.triggers[0].identifier, to: subscriberId, payload: { firstName: 'Test' }, }); @@ -64,13 +64,13 @@ describe('Get activity feed - /notifications (GET) #novu-v2', async () => { it('should filter by channel', async function () { await novuClient.trigger({ - name: template.triggers[0].identifier, + workflowId: template.triggers[0].identifier, to: subscriberId, payload: { firstName: 'Test' }, }); await novuClient.trigger({ - name: smsOnlyTemplate.triggers[0].identifier, + workflowId: smsOnlyTemplate.triggers[0].identifier, to: subscriberId, payload: { firstName: 'Test', @@ -78,7 +78,7 @@ describe('Get activity feed - /notifications (GET) #novu-v2', async () => { }); await novuClient.trigger({ - name: smsOnlyTemplate.triggers[0].identifier, + workflowId: smsOnlyTemplate.triggers[0].identifier, to: subscriberId, payload: { firstName: 'Test', @@ -86,7 +86,7 @@ describe('Get activity feed - /notifications (GET) #novu-v2', async () => { }); await session.awaitRunningJobs([template._id, smsOnlyTemplate._id]); - novuClient.notifications.list({ page: 0, transactionId: ChannelTypeEnum.Sms }); + await novuClient.notifications.list({ page: 0, transactionId: ChannelTypeEnum.Sms }); const body = await novuClient.notifications.list({ page: 0, channels: [ChannelTypeEnum.Sms] }); const activities = body.result; @@ -104,7 +104,7 @@ describe('Get activity feed - /notifications (GET) #novu-v2', async () => { it('should filter by templateId', async function () { await novuClient.trigger({ - name: smsOnlyTemplate.triggers[0].identifier, + workflowId: smsOnlyTemplate.triggers[0].identifier, to: subscriberId, payload: { firstName: 'Test', @@ -112,13 +112,13 @@ describe('Get activity feed - /notifications (GET) #novu-v2', async () => { }); await novuClient.trigger({ - name: template.triggers[0].identifier, + workflowId: template.triggers[0].identifier, to: subscriberId, payload: { firstName: 'Test' }, }); await novuClient.trigger({ - name: template.triggers[0].identifier, + workflowId: template.triggers[0].identifier, to: subscriberId, payload: { firstName: 'Test' }, }); @@ -146,7 +146,7 @@ describe('Get activity feed - /notifications (GET) #novu-v2', async () => { it('should filter by email', async function () { await novuClient.trigger({ - name: template.triggers[0].identifier, + workflowId: template.triggers[0].identifier, to: { subscriberId: SubscriberRepository.createObjectId(), email: 'test@email.coms', @@ -156,7 +156,7 @@ describe('Get activity feed - /notifications (GET) #novu-v2', async () => { }, }); await novuClient.trigger({ - name: template.triggers[0].identifier, + workflowId: template.triggers[0].identifier, to: { subscriberId: SubscriberRepository.createObjectId(), }, @@ -166,7 +166,7 @@ describe('Get activity feed - /notifications (GET) #novu-v2', async () => { }); await novuClient.trigger({ - name: template.triggers[0].identifier, + workflowId: template.triggers[0].identifier, to: SubscriberRepository.createObjectId(), payload: { firstName: 'Test', @@ -174,7 +174,7 @@ describe('Get activity feed - /notifications (GET) #novu-v2', async () => { }); await novuClient.trigger({ - name: template.triggers[0].identifier, + workflowId: template.triggers[0].identifier, to: SubscriberRepository.createObjectId(), payload: { firstName: 'Test', @@ -182,7 +182,7 @@ describe('Get activity feed - /notifications (GET) #novu-v2', async () => { }); await novuClient.trigger({ - name: template.triggers[0].identifier, + workflowId: template.triggers[0].identifier, to: subscriberId, payload: { firstName: 'Test', @@ -200,7 +200,7 @@ describe('Get activity feed - /notifications (GET) #novu-v2', async () => { const subscriberIdToCreate = `${SubscriberRepository.createObjectId()}some-test`; await novuClient.trigger({ - name: template.triggers[0].identifier, + workflowId: template.triggers[0].identifier, to: { subscriberId: subscriberIdToCreate, email: 'test@email.coms', @@ -210,7 +210,7 @@ describe('Get activity feed - /notifications (GET) #novu-v2', async () => { }, }); await novuClient.trigger({ - name: template.triggers[0].identifier, + workflowId: template.triggers[0].identifier, to: SubscriberRepository.createObjectId(), payload: { firstName: 'Test', @@ -218,14 +218,14 @@ describe('Get activity feed - /notifications (GET) #novu-v2', async () => { }); await novuClient.trigger({ - name: template.triggers[0].identifier, + workflowId: template.triggers[0].identifier, to: SubscriberRepository.createObjectId(), payload: { firstName: 'Test', }, }); await novuClient.trigger({ - name: template.triggers[0].identifier, + workflowId: template.triggers[0].identifier, to: subscriberId, payload: { firstName: 'Test', @@ -247,7 +247,7 @@ describe('Get activity feed - /notifications (GET) #novu-v2', async () => { const subscriberIdToDelete = `${SubscriberRepository.createObjectId()}`; await novuClient.trigger({ - name: templateToDelete.triggers[0].identifier, + workflowId: templateToDelete.triggers[0].identifier, to: subscriberIdToDelete, payload: { firstName: 'Test' }, }); diff --git a/apps/api/src/app/notifications/e2e/get-activity-graph-stats.e2e.ts b/apps/api/src/app/notifications/e2e/get-activity-graph-stats.e2e.ts index 013213581a7..a92793abb8a 100644 --- a/apps/api/src/app/notifications/e2e/get-activity-graph-stats.e2e.ts +++ b/apps/api/src/app/notifications/e2e/get-activity-graph-stats.e2e.ts @@ -39,13 +39,13 @@ describe('Get activity feed graph stats - /notifications/graph/stats (GET) #novu it('should get the current activity feed graph stats', async function () { await novuClient.trigger({ - name: template.triggers[0].identifier, + workflowId: template.triggers[0].identifier, to: subscriberId, payload: { firstName: 'Test' }, }); await novuClient.trigger({ - name: template.triggers[0].identifier, + workflowId: template.triggers[0].identifier, to: subscriberId, payload: { firstName: 'Test' }, }); diff --git a/apps/api/src/app/notifications/e2e/get-activity-stats.e2e.ts b/apps/api/src/app/notifications/e2e/get-activity-stats.e2e.ts index 3964404f839..91c9739a699 100644 --- a/apps/api/src/app/notifications/e2e/get-activity-stats.e2e.ts +++ b/apps/api/src/app/notifications/e2e/get-activity-stats.e2e.ts @@ -51,13 +51,13 @@ describe('Get activity stats - /notifications/stats (GET) #novu-v2', async () => it('should retrieve last month and last week activity', async function () { await novuClient.trigger({ - name: template.triggers[0].identifier, + workflowId: template.triggers[0].identifier, to: subscriberId, payload: { firstName: 'Test' }, }); await novuClient.trigger({ - name: template.triggers[0].identifier, + workflowId: template.triggers[0].identifier, to: subscriberId, payload: { firstName: 'Test' }, }); diff --git a/apps/api/src/app/shared/framework/swagger/sdk.decorators.ts b/apps/api/src/app/shared/framework/swagger/sdk.decorators.ts index be0f2bfa623..336482570b9 100644 --- a/apps/api/src/app/shared/framework/swagger/sdk.decorators.ts +++ b/apps/api/src/app/shared/framework/swagger/sdk.decorators.ts @@ -1,6 +1,7 @@ import { applyDecorators } from '@nestjs/common'; -import { ApiExtension, ApiParam } from '@nestjs/swagger'; +import { ApiExtension, ApiParam, ApiProperty } from '@nestjs/swagger'; import { ApiParamOptions } from '@nestjs/swagger/dist/decorators/api-param.decorator'; +import { ApiPropertyOptions } from '@nestjs/swagger/dist/decorators/api-property.decorator'; /** * Sets the method name for the SDK. @@ -69,24 +70,30 @@ class SDKOverrideOptions { nameOverride?: string; } -function overloadOptions(options: ApiParamOptions, sdkOverrideOptions: SDKOverrideOptions) { - let finalOptions = options; - if (sdkOverrideOptions.nameOverride) { - finalOptions = { - ...finalOptions, - 'x-speakeasy-name-override': sdkOverrideOptions.nameOverride, - } as unknown as ApiParamOptions; - } - - return finalOptions as ApiParamOptions; -} - export function SdkApiParam(options: ApiParamOptions, sdkOverrideOptions?: SDKOverrideOptions) { - const finalOptions = sdkOverrideOptions ? overloadOptions(options, sdkOverrideOptions) : options; + let finalOptions: ApiParamOptions; + if (sdkOverrideOptions) { + finalOptions = sdkOverrideOptions.nameOverride + ? ({ ...options, 'x-speakeasy-name-override': sdkOverrideOptions.nameOverride } as unknown as ApiParamOptions) + : options; + } else { + finalOptions = options; + } return applyDecorators(ApiParam(finalOptions)); } +export function SdkApiProperty(options: ApiPropertyOptions, sdkOverrideOptions?: SDKOverrideOptions) { + let finalOptions: ApiPropertyOptions; + if (sdkOverrideOptions) { + finalOptions = sdkOverrideOptions.nameOverride + ? ({ ...options, 'x-speakeasy-name-override': sdkOverrideOptions.nameOverride } as unknown as ApiPropertyOptions) + : options; + } else { + finalOptions = options; + } + return applyDecorators(ApiProperty(finalOptions)); +} /** * Sets the pagination for the SDK. * @param {string} override - The override for the limit parameter. diff --git a/apps/api/src/app/subscribers/e2e/get-notifications-feed.e2e.ts b/apps/api/src/app/subscribers/e2e/get-notifications-feed.e2e.ts index ca152c173bd..a8d55fd5305 100644 --- a/apps/api/src/app/subscribers/e2e/get-notifications-feed.e2e.ts +++ b/apps/api/src/app/subscribers/e2e/get-notifications-feed.e2e.ts @@ -22,14 +22,14 @@ describe('Get Notifications feed - /:subscriberId/notifications/feed (GET) #novu }); it('should throw exception on invalid subscriber id', async function () { - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); await session.awaitRunningJobs(template._id); const notificationsFeedResponse = (await novuClient.subscribers.notifications.feed({ limit: 5, subscriberId })) .result; expect(notificationsFeedResponse.pageSize).to.equal(5); - const { error, successfulBody } = await expectSdkExceptionGeneric(() => + const { error } = await expectSdkExceptionGeneric(() => novuClient.subscribers.notifications.feed({ subscriberId: `${subscriberId}111`, seen: false, @@ -44,7 +44,7 @@ describe('Get Notifications feed - /:subscriberId/notifications/feed (GET) #novu }); it('should throw exception when invalid payload query param is passed', async function () { - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); await session.awaitRunningJobs(template._id); @@ -63,10 +63,10 @@ describe('Get Notifications feed - /:subscriberId/notifications/feed (GET) #novu const partialPayload = { foo: 123 }; const payload = { ...partialPayload, bar: 'bar' }; - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); await session.awaitRunningJobs(template._id); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId, payload }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId, payload }); await session.awaitRunningJobs(template._id); const payloadQueryValue = Buffer.from(JSON.stringify(partialPayload)).toString('base64'); @@ -82,10 +82,10 @@ describe('Get Notifications feed - /:subscriberId/notifications/feed (GET) #novu const partialPayload = { foo: { bar: 123 } }; const payload = { ...partialPayload, baz: 'baz' }; - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); await session.awaitRunningJobs(template._id); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId, payload }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId, payload }); await session.awaitRunningJobs(template._id); const payloadQueryValue = Buffer.from(JSON.stringify(partialPayload)).toString('base64'); diff --git a/apps/api/src/app/subscribers/e2e/get-unseen-count.e2e.ts b/apps/api/src/app/subscribers/e2e/get-unseen-count.e2e.ts index 44be6402c72..be18617fa6a 100644 --- a/apps/api/src/app/subscribers/e2e/get-unseen-count.e2e.ts +++ b/apps/api/src/app/subscribers/e2e/get-unseen-count.e2e.ts @@ -23,7 +23,7 @@ describe('Get Unseen Count - /:subscriberId/notifications/unseen (GET) #novu-v2' }); it('should throw exception on invalid subscriber id', async function () { - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); await session.awaitRunningJobs(template._id); diff --git a/apps/api/src/app/subscribers/e2e/mark-all-subscriber-messages.e2e.ts b/apps/api/src/app/subscribers/e2e/mark-all-subscriber-messages.e2e.ts index 766a4c7a52f..3ddef40e7b4 100644 --- a/apps/api/src/app/subscribers/e2e/mark-all-subscriber-messages.e2e.ts +++ b/apps/api/src/app/subscribers/e2e/mark-all-subscriber-messages.e2e.ts @@ -39,11 +39,11 @@ describe('Mark All Subscriber Messages - /subscribers/:subscriberId/messages/mar it('should mark all the subscriber messages as read', async function () { const { subscriberId } = session; - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); await session.awaitRunningJobs(template._id); @@ -71,11 +71,11 @@ describe('Mark All Subscriber Messages - /subscribers/:subscriberId/messages/mar it('should not mark all the messages as read if they are already read', async function () { const { subscriberId } = session; - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); await session.awaitRunningJobs(template._id); @@ -114,11 +114,11 @@ describe('Mark All Subscriber Messages - /subscribers/:subscriberId/messages/mar it('should mark all the subscriber messages as unread', async function () { const { subscriberId } = session; - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); await session.awaitRunningJobs(template._id); @@ -157,11 +157,11 @@ describe('Mark All Subscriber Messages - /subscribers/:subscriberId/messages/mar it('should mark all the subscriber messages as seen', async function () { const { subscriberId } = session; - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); await session.awaitRunningJobs(template._id); @@ -189,11 +189,11 @@ describe('Mark All Subscriber Messages - /subscribers/:subscriberId/messages/mar it('should mark all the subscriber messages as unseen', async function () { const { subscriberId } = session; - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); await session.awaitRunningJobs(template._id); diff --git a/apps/api/src/app/subscribers/e2e/mark-as-by-mark.e2e.ts b/apps/api/src/app/subscribers/e2e/mark-as-by-mark.e2e.ts index 1a568a0b5b7..dcebfcee2ef 100644 --- a/apps/api/src/app/subscribers/e2e/mark-as-by-mark.e2e.ts +++ b/apps/api/src/app/subscribers/e2e/mark-as-by-mark.e2e.ts @@ -34,7 +34,7 @@ describe('Mark as Seen - /widgets/messages/mark-as (POST) #novu-v2', async () => }); beforeEach(async () => { - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); await session.awaitRunningJobs(template._id); subscriber = await getSubscriber(session, subscriberRepository, subscriberId); diff --git a/apps/api/src/app/widgets/e2e/get-count.e2e.ts b/apps/api/src/app/widgets/e2e/get-count.e2e.ts index a1f7d27e48c..7d6bbad342d 100644 --- a/apps/api/src/app/widgets/e2e/get-count.e2e.ts +++ b/apps/api/src/app/widgets/e2e/get-count.e2e.ts @@ -62,9 +62,9 @@ describe('Count - GET /widget/notifications/count #novu-v1', function () { }); it('should return unseen count', async function () { - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); await session.awaitRunningJobs(template._id); @@ -78,9 +78,9 @@ describe('Count - GET /widget/notifications/count #novu-v1', function () { }); it('should return unseen count after on message was seen', async function () { - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); await session.awaitRunningJobs(template._id); @@ -108,9 +108,9 @@ describe('Count - GET /widget/notifications/count #novu-v1', function () { }); it('should return unseen count after on message was read', async function () { - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); await session.awaitRunningJobs(template._id); @@ -141,9 +141,9 @@ describe('Count - GET /widget/notifications/count #novu-v1', function () { }); it('should return unseen count by limit', async function () { - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); await session.awaitRunningJobs(template._id); @@ -204,8 +204,8 @@ describe('Count - GET /widget/notifications/count #novu-v1', function () { }); it('should return default on string non numeric(NaN) value', async function () { - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); await session.awaitRunningJobs(template._id); @@ -214,8 +214,8 @@ describe('Count - GET /widget/notifications/count #novu-v1', function () { }); it('should return parse numeric string to number', async function () { - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); await session.awaitRunningJobs(template._id); @@ -249,9 +249,9 @@ describe('Count - GET /widget/notifications/count #novu-v1', function () { }); it('should return unseen count with a seen filter', async function () { - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); await session.awaitRunningJobs(template._id); @@ -278,9 +278,9 @@ describe('Count - GET /widget/notifications/count #novu-v1', function () { }); it('should return unread count with a read filter', async function () { - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); await session.awaitRunningJobs(template._id); if (!subscriberProfile) throw new Error('Subscriber profile is null'); @@ -312,9 +312,9 @@ describe('Count - GET /widget/notifications/count #novu-v1', function () { }); it('should return unseen count after mark as request', async function () { - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); await session.awaitRunningJobs(template._id); diff --git a/apps/api/src/app/widgets/e2e/get-notification-feed.e2e.ts b/apps/api/src/app/widgets/e2e/get-notification-feed.e2e.ts index 3fdc0dd7aea..3ae8dd3e328 100644 --- a/apps/api/src/app/widgets/e2e/get-notification-feed.e2e.ts +++ b/apps/api/src/app/widgets/e2e/get-notification-feed.e2e.ts @@ -53,8 +53,8 @@ describe('GET /widget/notifications/feed #novu-v1', function () { */ template = await session.createTemplate(); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); await session.awaitRunningJobs(template._id); @@ -63,8 +63,8 @@ describe('GET /widget/notifications/feed #novu-v1', function () { }); it('should fetch a feed without filters', async function () { - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); await session.awaitRunningJobs(template._id); @@ -73,8 +73,8 @@ describe('GET /widget/notifications/feed #novu-v1', function () { }); it('should filter only unseen messages', async function () { - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); await session.awaitRunningJobs(template._id); @@ -98,8 +98,8 @@ describe('GET /widget/notifications/feed #novu-v1', function () { }); it('should return seen and unseen', async function () { - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); await session.awaitRunningJobs(template._id); @@ -126,8 +126,8 @@ describe('GET /widget/notifications/feed #novu-v1', function () { }); it('should include subscriber object', async function () { - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); await session.awaitRunningJobs(template._id); @@ -137,7 +137,7 @@ describe('GET /widget/notifications/feed #novu-v1', function () { }); it('should include hasMore when there is more notification', async function () { - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); await session.awaitRunningJobs(template._id); @@ -148,7 +148,7 @@ describe('GET /widget/notifications/feed #novu-v1', function () { expect(feed.hasMore).to.be.equal(false); for (let i = 0; i < 10; i += 1) { - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); } await session.awaitRunningJobs(template._id); @@ -161,7 +161,7 @@ describe('GET /widget/notifications/feed #novu-v1', function () { }); it('should throw exception when invalid payload query param is passed', async function () { - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); await session.awaitRunningJobs(template._id); @@ -181,10 +181,10 @@ describe('GET /widget/notifications/feed #novu-v1', function () { const partialPayload = { foo: 123 }; const payload = { ...partialPayload, bar: 'bar' }; - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); await session.awaitRunningJobs(template._id); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId, payload }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId, payload }); await session.awaitRunningJobs(template._id); const payloadQueryValue = Buffer.from(JSON.stringify(partialPayload)).toString('base64'); @@ -198,10 +198,10 @@ describe('GET /widget/notifications/feed #novu-v1', function () { const partialPayload = { foo: { bar: 123 } }; const payload = { ...partialPayload, baz: 'baz' }; - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); await session.awaitRunningJobs(template._id); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId, payload }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId, payload }); await session.awaitRunningJobs(template._id); const payloadQueryValue = Buffer.from(JSON.stringify(partialPayload)).toString('base64'); diff --git a/apps/api/src/app/widgets/e2e/get-unread-count.e2e.ts b/apps/api/src/app/widgets/e2e/get-unread-count.e2e.ts index 178c85af9b5..abce81d889e 100644 --- a/apps/api/src/app/widgets/e2e/get-unread-count.e2e.ts +++ b/apps/api/src/app/widgets/e2e/get-unread-count.e2e.ts @@ -44,9 +44,9 @@ describe('Unread Count - GET /widget/notifications/unread #novu-v1', function () }); it('should return unread count with no query', async function () { - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); await session.awaitRunningJobs(template._id); @@ -73,9 +73,9 @@ describe('Unread Count - GET /widget/notifications/unread #novu-v1', function () }); it('should return unread count with query read false', async function () { - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); await session.awaitRunningJobs(template._id); @@ -102,9 +102,9 @@ describe('Unread Count - GET /widget/notifications/unread #novu-v1', function () }); it('should return unread count with query read true', async function () { - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); await session.awaitRunningJobs(template._id); diff --git a/apps/api/src/app/widgets/e2e/get-unseen-count.e2e.ts b/apps/api/src/app/widgets/e2e/get-unseen-count.e2e.ts index 9f6c0a30fa8..d50fbe1a7c7 100644 --- a/apps/api/src/app/widgets/e2e/get-unseen-count.e2e.ts +++ b/apps/api/src/app/widgets/e2e/get-unseen-count.e2e.ts @@ -62,9 +62,9 @@ describe('Unseen Count - GET /widget/notifications/unseen #novu-v1', function () }); it('should return unseen count with no query', async function () { - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); await session.awaitRunningJobs(template._id); @@ -91,9 +91,9 @@ describe('Unseen Count - GET /widget/notifications/unseen #novu-v1', function () }); it('should return unseen count with query seen false', async function () { - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); await session.awaitRunningJobs(template._id); @@ -120,9 +120,9 @@ describe('Unseen Count - GET /widget/notifications/unseen #novu-v1', function () }); it('should return unseen count with query seen true', async function () { - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); await session.awaitRunningJobs(template._id); @@ -149,9 +149,9 @@ describe('Unseen Count - GET /widget/notifications/unseen #novu-v1', function () }); it('should return unseen count after mark as request', async function () { - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); await session.awaitRunningJobs(template._id); diff --git a/apps/api/src/app/widgets/e2e/mark-all-as-read.e2e.ts b/apps/api/src/app/widgets/e2e/mark-all-as-read.e2e.ts index 2a5dc6a0298..807032dab86 100644 --- a/apps/api/src/app/widgets/e2e/mark-all-as-read.e2e.ts +++ b/apps/api/src/app/widgets/e2e/mark-all-as-read.e2e.ts @@ -43,9 +43,9 @@ describe('Mark all as read - /widgets/messages/seen (POST) #novu-v1', function ( }); it('should mark all as seen', async function () { - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); await session.awaitRunningJobs(template._id); @@ -67,9 +67,9 @@ describe('Mark all as read - /widgets/messages/seen (POST) #novu-v1', function ( }); it('should mark all as read', async function () { - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); await session.awaitRunningJobs(template._id); diff --git a/apps/api/src/app/widgets/e2e/mark-as-by-mark.e2e.ts b/apps/api/src/app/widgets/e2e/mark-as-by-mark.e2e.ts index 73d3a85f5d7..f6d5fcd7921 100644 --- a/apps/api/src/app/widgets/e2e/mark-as-by-mark.e2e.ts +++ b/apps/api/src/app/widgets/e2e/mark-as-by-mark.e2e.ts @@ -45,7 +45,7 @@ describe('Mark as Seen - /widgets/messages/mark-as (POST) #novu-v1', async () => }); beforeEach(async () => { - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); await session.awaitRunningJobs(template._id); message = await getMessage(session, messageRepository, subscriber); diff --git a/apps/api/src/app/widgets/e2e/mark-as.e2e.ts b/apps/api/src/app/widgets/e2e/mark-as.e2e.ts index a8a77501b97..38798d0eb7a 100644 --- a/apps/api/src/app/widgets/e2e/mark-as.e2e.ts +++ b/apps/api/src/app/widgets/e2e/mark-as.e2e.ts @@ -32,9 +32,9 @@ describe('Mark as Seen - /widgets/messages/markAs (POST) #novu-v1', async () => }) .expect(201); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); await session.awaitRunningJobs(template._id); const { token } = body.data; const messages = await messageRepository.findBySubscriberChannel( diff --git a/apps/api/src/app/widgets/e2e/remove-all-messages.e2e.ts b/apps/api/src/app/widgets/e2e/remove-all-messages.e2e.ts index efb1bb71aa3..fd1669334b0 100644 --- a/apps/api/src/app/widgets/e2e/remove-all-messages.e2e.ts +++ b/apps/api/src/app/widgets/e2e/remove-all-messages.e2e.ts @@ -44,9 +44,9 @@ describe('Remove all messages - /widgets/messages (DELETE) #novu-v1', function ( }); it('should remove all messages', async function () { - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); await session.awaitRunningJobs(template._id); @@ -77,11 +77,11 @@ describe('Remove all messages - /widgets/messages (DELETE) #novu-v1', function ( const _feedId = templateWithFeed?.steps[0]?.template?._feedId; - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: templateWithFeed.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: templateWithFeed.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: templateWithFeed.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: templateWithFeed.triggers[0].identifier, to: subscriberId }); await session.awaitRunningJobs(templateWithFeed._id); await session.awaitRunningJobs(template._id); diff --git a/apps/api/src/app/widgets/e2e/remove-messages-bulk.e2e.ts b/apps/api/src/app/widgets/e2e/remove-messages-bulk.e2e.ts index d583aae8ea9..1659be0d034 100644 --- a/apps/api/src/app/widgets/e2e/remove-messages-bulk.e2e.ts +++ b/apps/api/src/app/widgets/e2e/remove-messages-bulk.e2e.ts @@ -45,9 +45,9 @@ describe('Remove messages by bulk - /widgets/messages/bulk/delete (POST) #novu-v }); it('should remove messages by bulk', async function () { - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); await session.awaitRunningJobs(template._id); @@ -82,9 +82,9 @@ describe('Remove messages by bulk - /widgets/messages/bulk/delete (POST) #novu-v }); it('should throw an exception when message ids were not provided', async function () { - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); - await novuClient.trigger({ name: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); + await novuClient.trigger({ workflowId: template.triggers[0].identifier, to: subscriberId }); await session.awaitRunningJobs(template._id); diff --git a/libs/internal-sdk/src/models/components/index.ts b/libs/internal-sdk/src/models/components/index.ts index 91a8dcacd91..b8374b20e00 100644 --- a/libs/internal-sdk/src/models/components/index.ts +++ b/libs/internal-sdk/src/models/components/index.ts @@ -123,4 +123,3 @@ export * from "./updatesubscriberpreferencerequestdto.js"; export * from "./updatesubscriberpreferenceresponsedto.js"; export * from "./updatesubscriberrequestdto.js"; export * from "./workflowresponse.js"; -export * from "./workflowtostepcontrolvaluesdto.js"; diff --git a/libs/internal-sdk/src/models/components/triggereventrequestdto.ts b/libs/internal-sdk/src/models/components/triggereventrequestdto.ts index 144ec312385..5737051eb25 100644 --- a/libs/internal-sdk/src/models/components/triggereventrequestdto.ts +++ b/libs/internal-sdk/src/models/components/triggereventrequestdto.ts @@ -3,6 +3,7 @@ */ import * as z from "zod"; +import { remap as remap$ } from "../../lib/primitives.js"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; @@ -24,12 +25,6 @@ import { TopicPayloadDto$Outbound, TopicPayloadDto$outboundSchema, } from "./topicpayloaddto.js"; -import { - WorkflowToStepControlValuesDto, - WorkflowToStepControlValuesDto$inboundSchema, - WorkflowToStepControlValuesDto$Outbound, - WorkflowToStepControlValuesDto$outboundSchema, -} from "./workflowtostepcontrolvaluesdto.js"; export type One = TopicPayloadDto | SubscriberPayloadDto | string; @@ -62,7 +57,7 @@ export type TriggerEventRequestDto = { /** * The trigger identifier of the workflow you wish to send. This identifier can be found on the workflow page. */ - name: string; + workflowId: string; /** * The payload object is used to pass additional custom information that could be * @@ -71,10 +66,6 @@ export type TriggerEventRequestDto = { * This data will also be available when fetching the notifications feed from the API to display certain parts of the UI. */ payload?: { [k: string]: any } | undefined; - /** - * A URL to bridge for additional processing. - */ - bridgeUrl?: string | undefined; /** * This could be used to override provider specific configurations */ @@ -105,10 +96,6 @@ export type TriggerEventRequestDto = { * Existing tenants will be updated with the provided details. */ tenant?: TenantPayloadDto | string | undefined; - /** - * Additional control configurations. - */ - controls?: WorkflowToStepControlValuesDto | undefined; }; /** @internal */ @@ -314,7 +301,6 @@ export const TriggerEventRequestDto$inboundSchema: z.ZodType< > = z.object({ name: z.string(), payload: z.record(z.any()).optional(), - bridgeUrl: z.string().optional(), overrides: z.record(z.record(z.any())).optional(), to: z.union([ TopicPayloadDto$inboundSchema, @@ -331,14 +317,16 @@ export const TriggerEventRequestDto$inboundSchema: z.ZodType< transactionId: z.string().optional(), actor: z.union([SubscriberPayloadDto$inboundSchema, z.string()]).optional(), tenant: z.union([TenantPayloadDto$inboundSchema, z.string()]).optional(), - controls: WorkflowToStepControlValuesDto$inboundSchema.optional(), +}).transform((v) => { + return remap$(v, { + "name": "workflowId", + }); }); /** @internal */ export type TriggerEventRequestDto$Outbound = { name: string; payload?: { [k: string]: any } | undefined; - bridgeUrl?: string | undefined; overrides?: { [k: string]: { [k: string]: any } } | undefined; to: | TopicPayloadDto$Outbound @@ -348,7 +336,6 @@ export type TriggerEventRequestDto$Outbound = { transactionId?: string | undefined; actor?: SubscriberPayloadDto$Outbound | string | undefined; tenant?: TenantPayloadDto$Outbound | string | undefined; - controls?: WorkflowToStepControlValuesDto$Outbound | undefined; }; /** @internal */ @@ -357,9 +344,8 @@ export const TriggerEventRequestDto$outboundSchema: z.ZodType< z.ZodTypeDef, TriggerEventRequestDto > = z.object({ - name: z.string(), + workflowId: z.string(), payload: z.record(z.any()).optional(), - bridgeUrl: z.string().optional(), overrides: z.record(z.record(z.any())).optional(), to: z.union([ TopicPayloadDto$outboundSchema, @@ -376,7 +362,10 @@ export const TriggerEventRequestDto$outboundSchema: z.ZodType< transactionId: z.string().optional(), actor: z.union([SubscriberPayloadDto$outboundSchema, z.string()]).optional(), tenant: z.union([TenantPayloadDto$outboundSchema, z.string()]).optional(), - controls: WorkflowToStepControlValuesDto$outboundSchema.optional(), +}).transform((v) => { + return remap$(v, { + workflowId: "name", + }); }); /** diff --git a/libs/internal-sdk/src/models/components/workflowtostepcontrolvaluesdto.ts b/libs/internal-sdk/src/models/components/workflowtostepcontrolvaluesdto.ts deleted file mode 100644 index ed647fe9bb7..00000000000 --- a/libs/internal-sdk/src/models/components/workflowtostepcontrolvaluesdto.ts +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - */ - -import * as z from "zod"; -import { safeParse } from "../../lib/schemas.js"; -import { Result as SafeParseResult } from "../../types/fp.js"; -import { SDKValidationError } from "../errors/sdkvalidationerror.js"; - -export type WorkflowToStepControlValuesDto = { - /** - * A mapping of step IDs to their corresponding data. - */ - steps?: { [k: string]: { [k: string]: any } } | undefined; -}; - -/** @internal */ -export const WorkflowToStepControlValuesDto$inboundSchema: z.ZodType< - WorkflowToStepControlValuesDto, - z.ZodTypeDef, - unknown -> = z.object({ - steps: z.record(z.record(z.any())).optional(), -}); - -/** @internal */ -export type WorkflowToStepControlValuesDto$Outbound = { - steps?: { [k: string]: { [k: string]: any } } | undefined; -}; - -/** @internal */ -export const WorkflowToStepControlValuesDto$outboundSchema: z.ZodType< - WorkflowToStepControlValuesDto$Outbound, - z.ZodTypeDef, - WorkflowToStepControlValuesDto -> = z.object({ - steps: z.record(z.record(z.any())).optional(), -}); - -/** - * @internal - * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. - */ -export namespace WorkflowToStepControlValuesDto$ { - /** @deprecated use `WorkflowToStepControlValuesDto$inboundSchema` instead. */ - export const inboundSchema = WorkflowToStepControlValuesDto$inboundSchema; - /** @deprecated use `WorkflowToStepControlValuesDto$outboundSchema` instead. */ - export const outboundSchema = WorkflowToStepControlValuesDto$outboundSchema; - /** @deprecated use `WorkflowToStepControlValuesDto$Outbound` instead. */ - export type Outbound = WorkflowToStepControlValuesDto$Outbound; -} - -export function workflowToStepControlValuesDtoToJSON( - workflowToStepControlValuesDto: WorkflowToStepControlValuesDto, -): string { - return JSON.stringify( - WorkflowToStepControlValuesDto$outboundSchema.parse( - workflowToStepControlValuesDto, - ), - ); -} - -export function workflowToStepControlValuesDtoFromJSON( - jsonString: string, -): SafeParseResult { - return safeParse( - jsonString, - (x) => WorkflowToStepControlValuesDto$inboundSchema.parse(JSON.parse(x)), - `Failed to parse 'WorkflowToStepControlValuesDto' from JSON`, - ); -}