Skip to content

Commit

Permalink
chore(root): Release 2024-12-05 12:46 (#7221)
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored Dec 5, 2024
2 parents 0e2d170 + da531b2 commit 3d81459
Show file tree
Hide file tree
Showing 200 changed files with 9,352 additions and 2,449 deletions.
6 changes: 5 additions & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"words": [
"ABNF",
"addrs",
"subscriberpayloaddto",
"adresses",
"sdkerror",
"africas",
Expand Down Expand Up @@ -708,7 +709,10 @@
"rstrip",
"truncatewords",
"xmlschema",
"jsonify"
"jsonify",
"touchpoint",
"Angularjs",
"navigatable"
],
"flagWords": [],
"patterns": [
Expand Down
2 changes: 1 addition & 1 deletion .source
4 changes: 2 additions & 2 deletions apps/api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@novu/api",
"version": "2.1.0",
"version": "2.1.1",
"description": "description",
"author": "",
"private": "true",
Expand Down Expand Up @@ -59,7 +59,7 @@
"@sentry/tracing": "^7.40.0",
"@types/newrelic": "^9.14.0",
"@upstash/ratelimit": "^0.4.4",
"@novu/api": "^0.0.1-alpha.39",
"@novu/api": "^0.0.1-alpha.56",
"axios": "^1.6.8",
"liquidjs": "^10.13.1",
"bcrypt": "^5.0.0",
Expand Down
2 changes: 0 additions & 2 deletions apps/api/src/.env.development
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ API_RATE_LIMIT_MAXIMUM_UNLIMITED_TRIGGER=
API_RATE_LIMIT_MAXIMUM_UNLIMITED_CONFIGURATION=
API_RATE_LIMIT_MAXIMUM_UNLIMITED_GLOBAL=

PR_PREVIEW_ROOT_URL=dev-web-novu.netlify.app

HUBSPOT_INVITE_NUDGE_EMAIL_USER_LIST_ID=
HUBSPOT_PRIVATE_APP_ACCESS_TOKEN=

Expand Down
4 changes: 3 additions & 1 deletion apps/api/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,9 @@ modules.push(
client: new Client({
secretKey: process.env.NOVU_INTERNAL_SECRET_KEY,
strictAuthentication:
process.env.NODE_ENV === 'production' || process.env.NOVU_STRICT_AUTHENTICATION_ENABLED === 'true',
process.env.NODE_ENV === 'production' ||
process.env.NODE_ENV === 'dev' ||
process.env.NOVU_STRICT_AUTHENTICATION_ENABLED === 'true',
}),
controllerDecorators: [ApiExcludeController()],
workflows: [usageLimitsWorkflow],
Expand Down
24 changes: 20 additions & 4 deletions apps/api/src/app/auth/services/passport/jwt.strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,33 @@ export class JwtStrategy extends PassportStrategy(Strategy) {
throw new UnauthorizedException();
}

await this.resolveEnvironmentId(req, session);
const environmentId = this.resolveEnvironmentId(req, session);

// eslint-disable-next-line no-param-reassign
session.environmentId = environmentId;

if (session.environmentId) {
const environment = await this.environmentRepository.findOne(
{
_id: session.environmentId,
_organizationId: session.organizationId,
},
'_id'
);

if (!environment) {
throw new UnauthorizedException('Cannot find environment', JSON.stringify({ session }));
}
}

return session;
}

@Instrument()
async resolveEnvironmentId(req: http.IncomingMessage, session: UserSessionData) {
resolveEnvironmentId(req: http.IncomingMessage, session: UserSessionData) {
const environmentIdFromHeader =
(req.headers[HttpRequestHeaderKeysEnum.NOVU_ENVIRONMENT_ID.toLowerCase()] as string) || '';

// eslint-disable-next-line no-param-reassign
session.environmentId = environmentIdFromHeader;
return environmentIdFromHeader;
}
}
2 changes: 1 addition & 1 deletion apps/api/src/app/bridge/usecases/sync/sync.usecase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export class Sync {
environmentId: command.environmentId,
organizationId: command.organizationId,
userId: command.userId,
identifierOrInternalId: workflow._id,
workflowIdOrInternalId: workflow._id,
})
)
);
Expand Down
1 change: 1 addition & 0 deletions apps/api/src/app/environments-v1/novu-bridge-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export class NovuBridgeClient {

workflows.push(programmaticallyConstructedWorkflow);
}

this.novuRequestHandler = new NovuRequestHandler({
frameworkName,
workflows,
Expand Down
65 changes: 45 additions & 20 deletions apps/api/src/app/events/dtos/trigger-event-request.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
import { Type } from 'class-transformer';
import { ApiExtraModels, ApiProperty, ApiPropertyOptional, getSchemaPath } from '@nestjs/swagger';
import {
ControlsDto,
TriggerRecipients,
TriggerRecipientsTypeEnum,
TriggerRecipientSubscriber,
Expand All @@ -21,6 +20,26 @@ import {
import { CreateSubscriberRequestDto } from '../../subscribers/dtos';
import { UpdateTenantRequestDto } from '../../tenant/dtos';

export class WorkflowToStepControlValuesDto {
/**
* A mapping of step IDs to their corresponding data.
* Built for stateless triggering by the local studio, those values will not be persisted outside of the job scope
* First key is step id, second is controlId, value is the control value
* @type {Record<stepId, Data>}
* @optional
*/
@ApiProperty({
description: 'A mapping of step IDs to their corresponding data.',
type: 'object',
additionalProperties: {
type: 'object',
additionalProperties: true, // Allows any additional properties
},
required: false, // Indicates that this property is optional
})
steps?: Record<string, Record<string, unknown>>;
}

export class SubscriberPayloadDto extends CreateSubscriberRequestDto {}
export class TenantPayloadDto extends UpdateTenantRequestDto {}

Expand All @@ -32,9 +51,7 @@ export class TopicPayloadDto {
type: TriggerRecipientsTypeEnum;
}

@ApiExtraModels(SubscriberPayloadDto)
@ApiExtraModels(TenantPayloadDto)
@ApiExtraModels(TopicPayloadDto)
@ApiExtraModels(SubscriberPayloadDto, TenantPayloadDto, TopicPayloadDto)
export class TriggerEventRequestDto {
@ApiProperty({
description:
Expand All @@ -46,27 +63,27 @@ export class TriggerEventRequestDto {
name: string;

@ApiProperty({
description:
// eslint-disable-next-line max-len
`The payload object is used to pass additional custom information that could be used to render the workflow, or perform routing rules based on it.
description: `The payload object is used to pass additional custom information that could be
used to render the workflow, or perform routing rules based on it.
This data will also be available when fetching the notifications feed from the API to display certain parts of the UI.`,
type: 'object',
required: false,
additionalProperties: true,
example: {
comment_id: 'string',
post: {
text: 'string',
},
},
})
@ApiProperty({
type: 'object',
description: 'An optional payload object that can contain any properties',
required: false,
additionalProperties: true,
})
@IsObject()
@IsOptional()
payload?: Record<string, unknown>;

@ApiPropertyOptional({
description: 'A URL to bridge for additional processing.',
example: 'https://example.com/bridge',
})
@IsString()
@IsOptional()
bridgeUrl?: string;
Expand All @@ -80,6 +97,12 @@ export class TriggerEventRequestDto {
},
},
},
type: 'object',
additionalProperties: {
type: 'object',
additionalProperties: true, // Allows any additional properties
},
required: false, // Indicates that this property is optional
})
@IsObject()
@IsOptional()
Expand Down Expand Up @@ -107,17 +130,16 @@ export class TriggerEventRequestDto {
@IsDefined()
to: TriggerRecipients;

@ApiProperty({
description: 'A unique identifier for this transaction, we will generated a UUID if not provided.',
@ApiPropertyOptional({
description: 'A unique identifier for this transaction, we will generate a UUID if not provided.',
})
@IsString()
@IsOptional()
transactionId?: string;

@ApiProperty({
description: `It is used to display the Avatar of the provided actor's subscriber id or actor object.
If a new actor object is provided, we will create a new subscriber in our system
`,
If a new actor object is provided, we will create a new subscriber in our system`,
oneOf: [
{ type: 'string', description: 'Unique identifier of a subscriber in your systems' },
{ $ref: getSchemaPath(SubscriberPayloadDto) },
Expand All @@ -131,8 +153,7 @@ export class TriggerEventRequestDto {

@ApiProperty({
description: `It is used to specify a tenant context during trigger event.
Existing tenants will be updated with the provided details.
`,
Existing tenants will be updated with the provided details.`,
oneOf: [
{ type: 'string', description: 'Unique identifier of a tenant in your system' },
{ $ref: getSchemaPath(TenantPayloadDto) },
Expand All @@ -144,7 +165,11 @@ export class TriggerEventRequestDto {
@Type(() => TenantPayloadDto)
tenant?: TriggerTenantContext;

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

export class BulkTriggerEventDto {
Expand Down
18 changes: 13 additions & 5 deletions apps/api/src/app/events/dtos/trigger-event-response.dto.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,38 @@
import { IsBoolean, IsDefined, IsString } from 'class-validator';
import { IsBoolean, IsDefined, IsEnum, IsOptional, IsString } from 'class-validator';
import { TriggerEventStatusEnum } from '@novu/shared';
import { ApiProperty } from '@nestjs/swagger';

export class TriggerEventResponseDto {
@ApiProperty({
description: 'If trigger was acknowledged or not',
description: 'Indicates whether the trigger was acknowledged or not',
type: Boolean,
})
@IsBoolean()
@IsDefined()
acknowledged: boolean;

@ApiProperty({
description: 'Status for trigger',
description: 'Status of the trigger',
enum: TriggerEventStatusEnum,
})
@IsDefined()
@IsEnum(TriggerEventStatusEnum)
status: TriggerEventStatusEnum;

@ApiProperty({
description: 'In case of an error, this field will contain the error message',
description: 'In case of an error, this field will contain the error message(s)',
type: [String], // Specify that this is an array of strings
required: false, // Not required since it's optional
})
@IsOptional()
error?: string[];

@ApiProperty({
description: 'Transaction id for trigger',
description: 'The returned transaction ID of the trigger',
type: String, // Specify that this is a string
required: false, // Not required since it's optional
})
@IsOptional()
@IsString()
transactionId?: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,18 @@ export class TriggerEventToAllRequestDto {
name: string;

@ApiProperty({
description: `The payload object is used to pass additional custom information that could be used to render the template, or perform routing rules based on it.
This data will also be available when fetching the notifications feed from the API to display certain parts of the UI.`,
example: {
comment_id: 'string',
post: {
text: 'string',
},
},
type: 'object',
description: `The payload object is used to pass additional information that
could be used to render the template, or perform routing rules based on it.
For In-App channel, payload data are also available in <Inbox />`,
required: true,
additionalProperties: true,
})
@IsObject()
payload: Record<string, unknown>;
Expand Down
Loading

0 comments on commit 3d81459

Please sign in to comment.