Skip to content

Commit

Permalink
Merge branch 'main' into next
Browse files Browse the repository at this point in the history
  • Loading branch information
scopsy committed Aug 16, 2023
2 parents e697121 + 4a85177 commit 61299b2
Show file tree
Hide file tree
Showing 69 changed files with 13,787 additions and 8,540 deletions.
14 changes: 7 additions & 7 deletions apps/api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@novu/api",
"version": "0.17.2",
"version": "0.18.0",
"description": "description",
"author": "",
"private": "true",
Expand Down Expand Up @@ -37,12 +37,12 @@
"@nestjs/platform-express": "9.3.12",
"@nestjs/swagger": "^6.3.0",
"@nestjs/terminus": "9.2.1",
"@novu/application-generic": "^0.17.2",
"@novu/dal": "^0.17.2",
"@novu/node": "^0.17.2",
"@novu/shared": "^0.17.2",
"@novu/stateless": "^0.17.1",
"@novu/testing": "^0.17.2",
"@novu/application-generic": "^0.18.0",
"@novu/dal": "^0.18.0",
"@novu/node": "^0.18.0",
"@novu/shared": "^0.18.0",
"@novu/stateless": "^0.18.0",
"@novu/testing": "^0.18.0",
"@sendgrid/mail": "^7.6.0",
"@sentry/hub": "^7.40.0",
"@sentry/node": "^7.40.0",
Expand Down
8 changes: 4 additions & 4 deletions apps/inbound-mail/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@novu/inbound-mail",
"version": "0.17.2",
"version": "0.18.0",
"description": "",
"author": "",
"private": true,
Expand All @@ -19,8 +19,8 @@
"test": "echo \"No e2e tests, only build tests\""
},
"dependencies": {
"@novu/application-generic": "^0.17.2",
"@novu/shared": "^0.17.2",
"@novu/application-generic": "^0.18.0",
"@novu/shared": "^0.18.0",
"@sentry/node": "^7.12.1",
"bluebird": "^2.9.30",
"bullmq": "^3.10.2",
Expand All @@ -41,9 +41,9 @@
},
"devDependencies": {
"@types/express": "^4.17.8",
"@types/html-to-text": "^9.0.1",
"@types/node": "^14.14.6",
"@types/smtp-server": "^3.5.7",
"@types/html-to-text": "^9.0.1",
"cross-env": "^7.0.3",
"nodemon": "^2.0.7",
"prettier": "~2.8.0",
Expand Down
10 changes: 5 additions & 5 deletions apps/web/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@novu/web",
"version": "0.17.2",
"version": "0.18.0",
"private": true,
"scripts": {
"start": "cross-env PORT=4200 react-app-rewired start",
Expand Down Expand Up @@ -49,8 +49,8 @@
"@mantine/notifications": "^5.7.1",
"@mantine/prism": "^5.7.1",
"@mantine/spotlight": "^5.7.1",
"@novu/notification-center": "^0.17.2",
"@novu/shared": "^0.17.2",
"@novu/notification-center": "^0.18.0",
"@novu/shared": "^0.18.0",
"@segment/analytics-next": "^1.48.0",
"@sentry/react": "^7.40.0",
"@sentry/tracing": "^7.40.0",
Expand Down Expand Up @@ -127,8 +127,8 @@
"@babel/preset-react": "^7.13.13",
"@babel/preset-typescript": "^7.13.0",
"@babel/runtime": "^7.20.13",
"@novu/dal": "^0.17.2",
"@novu/testing": "^0.17.2",
"@novu/dal": "^0.18.0",
"@novu/testing": "^0.18.0",
"@storybook/addon-actions": "^6.4.14",
"@storybook/addon-essentials": "^6.4.14",
"@storybook/addon-links": "^6.4.14",
Expand Down
12 changes: 6 additions & 6 deletions apps/webhook/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@novu/webhook",
"version": "0.17.2",
"version": "0.18.0",
"description": "",
"author": "",
"private": true,
Expand All @@ -27,11 +27,11 @@
"@nestjs/platform-socket.io": "^9.2.1",
"@nestjs/swagger": "^6.3.0",
"@nestjs/terminus": "9.2.1",
"@novu/application-generic": "^0.17.2",
"@novu/dal": "^0.17.2",
"@novu/shared": "^0.17.2",
"@novu/stateless": "^0.17.1",
"@novu/testing": "^0.17.2",
"@novu/application-generic": "^0.18.0",
"@novu/dal": "^0.18.0",
"@novu/shared": "^0.18.0",
"@novu/stateless": "^0.18.0",
"@novu/testing": "^0.18.0",
"@sentry/node": "^6.3.3",
"axios": "^1.3.3",
"bull": "^4.4.0",
Expand Down
10 changes: 5 additions & 5 deletions apps/widget/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@novu/widget",
"version": "0.17.2",
"version": "0.18.0",
"private": true,
"scripts": {
"start": "craco start",
Expand Down Expand Up @@ -29,8 +29,8 @@
"@emotion/styled": "^11.6.0",
"@mantine/core": "4.2.12",
"@mantine/hooks": "4.2.12",
"@novu/notification-center": "^0.17.2",
"@novu/shared": "^0.17.2",
"@novu/notification-center": "^0.18.0",
"@novu/shared": "^0.18.0",
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
Expand Down Expand Up @@ -58,8 +58,8 @@
"@craco/craco": "^7.0.0",
"@emotion/babel-plugin": "^11.7.2",
"@faker-js/faker": "^6.0.0",
"@novu/dal": "^0.17.2",
"@novu/testing": "^0.17.2",
"@novu/dal": "^0.18.0",
"@novu/testing": "^0.18.0",
"@types/jest": "^29.5.0",
"@types/node": "^12.0.0",
"@types/react": "17.0.62",
Expand Down
12 changes: 6 additions & 6 deletions apps/worker/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@novu/worker",
"version": "0.17.2",
"version": "0.18.0",
"description": "description",
"author": "",
"private": "true",
Expand Down Expand Up @@ -29,11 +29,11 @@
"@nestjs/platform-express": "9.3.12",
"@nestjs/swagger": "^6.3.0",
"@nestjs/terminus": "9.2.1",
"@novu/application-generic": "^0.17.2",
"@novu/dal": "^0.17.2",
"@novu/shared": "^0.17.2",
"@novu/stateless": "^0.17.1",
"@novu/testing": "^0.17.2",
"@novu/application-generic": "^0.18.0",
"@novu/dal": "^0.18.0",
"@novu/shared": "^0.18.0",
"@novu/stateless": "^0.18.0",
"@novu/testing": "^0.18.0",
"@sentry/node": "^7.40.0",
"@sentry/tracing": "^7.40.0",
"@types/newrelic": "^9.13.0",
Expand Down
18 changes: 11 additions & 7 deletions apps/worker/src/app/workflow/usecases/run-job/run-job.usecase.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Injectable } from '@nestjs/common';
import { Injectable, Logger } from '@nestjs/common';
import { JobEntity, JobRepository, JobStatusEnum } from '@novu/dal';
import { StepTypeEnum } from '@novu/shared';
import * as Sentry from '@sentry/node';
Expand Down Expand Up @@ -30,12 +30,16 @@ export class RunJob {
const job = await this.jobRepository.findById(command.jobId);
if (!job) throw new PlatformException(`Job with id ${command.jobId} not found`);

this.logger?.assign({
transactionId: job.transactionId,
environmentId: job._environmentId,
organizationId: job._organizationId,
jobId: job._id,
});
try {
this.logger?.assign({
transactionId: job.transactionId,
environmentId: job._environmentId,
organizationId: job._organizationId,
jobId: job._id,
});
} catch (e) {
Logger.error(e, 'RunJob');
}

const canceled = await this.delayedEventIsCanceled(job);
if (canceled) {
Expand Down
18 changes: 9 additions & 9 deletions apps/ws/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@novu/ws",
"version": "0.17.2",
"version": "0.18.0",
"description": "",
"author": "",
"private": true,
Expand Down Expand Up @@ -28,14 +28,15 @@
"@nestjs/swagger": "^5.2.1",
"@nestjs/terminus": "^9.2.1",
"@nestjs/websockets": "9.3.2",
"@novu/application-generic": "^0.17.2",
"@novu/dal": "^0.17.2",
"@novu/shared": "^0.17.2",
"@novu/testing": "^0.17.2",
"@novu/application-generic": "^0.18.0",
"@novu/dal": "^0.18.0",
"@novu/shared": "^0.18.0",
"@novu/testing": "^0.18.0",
"@sentry/node": "^7.30.0",
"@socket.io/redis-adapter": "^7.2.0",
"bull": "^4.4.0",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.0",
"dotenv": "^8.2.0",
"envalid": "^7.1.0",
"helmet": "^6.0.1",
Expand All @@ -47,17 +48,16 @@
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"rxjs": "7.8.1",
"socket.io": "^4.5.4",
"class-validator": "^0.14.0",
"sinon": "^9.2.4"
"sinon": "^9.2.4",
"socket.io": "^4.5.4"
},
"devDependencies": {
"@nestjs/cli": "^9.0.0",
"@nestjs/schematics": "^7.3.1",
"@nestjs/testing": "9.3.12",
"@types/chai": "^4.2.11",
"@types/express": "^4.17.8",
"@types/jsonwebtoken": "^8.5.9",
"@types/chai": "^4.2.11",
"@types/mocha": "^8.2.3",
"@types/node": "^14.14.6",
"@types/socket.io": "^2.1.13",
Expand Down
78 changes: 78 additions & 0 deletions docs/docs/platform/handlebars.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
---
sidebar_position: 14
sidebar_label: Handlebars
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

# Handlebars Template

You can customize the notification (appearance and structure) the end users get using Handlebars. This is crucial for many cases, for example, when using the [digest engine](https://docs.novu.co/platform/digest/).

## Properties and their description

To be able to write handlebar templates to suit your needs, you'll first need to know the properties you have access to. Novu lets you access the following properties:

| Property | Description |
| ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------- |
| `step.events` | An array of all the events aggregated under in digest. This will be the "payload" object passed to each `trigger.event` sent in the digest period |
| `step.total_count` | The number of total events in this digest |
| `step.digest` | A `boolean` flag to indicate if we are in a digest mode right now

## Functions and their description

In addition to these properties, we also support the following functionality:

| Function | Description |
| ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------- |
| `{{#each array}}`<br/>`...`<br/>`{{/each}}` | This helps you iterate over an array. |
| `unique array "key"` | It lists all the unique values from an array when iterating over it. So for the array `[{ name: 'dog' }, { name: 'cat' }, { name: 'dog' }]`, <br/>if we iterate over the `animals` array and write`unique animals "name"`, we'll get 'dog' and 'cat' once each, even though dog appears twice in the array.|
| `{{equals item1 item2}}` | This lets you check equality of `item1` and `item2`. |
| `<div>`<br/>`{{name}}`<br/>`</div>` | You can render custom HTML by directly using these tags and placing variables in double braces as shown. <br/><br/> So, for `name:'Hello World'`, `<div>{{name}}</div>` would generate a separate div with 'Hello World' in it. |
| `<div>`<br/>`{{name}}`<br/>`</div>` | If your data has apostrophe in it, to ensure that it contains the apostrophe in the render as well, do the following:<br/><br/>Change `name: 'John' Doe'` to `name: "John' Doe"` to preserve the apostrophe after the first name.|
| `{{#if test_condition}}`<br/>`...`<br/>`{{else}}`<br/>`...`<br/>`{{/if}}` | This lets you write conditional statements. |
| `{pluralize variable “notification” “notifications”}}` | This checks the if the value of `variable` is more than 1 or not. It it is, it will use a plural value - `notifications` and if it isn't, a singular value will be used - `notification`. |
| `{{dateFormat date 'EEEE, MMMM Do yyyy'}}` | You can format the date using the `dateFormat` function. Here, `date: '2020-01-01` has been formatted into `Wednesday, January 1st 2020`.|
| `{{lowercase key}}` | This helps you use the `lowercase` handlebar helper function and turns the value of the specified key to its lowercase value. So, for `message: 'hEllo WORLD'`, if we write `{{lowercase message}}`, we'll end up with `hello world`|
| `{{uppercase key}}` | This helps you use the `uppercase` handlebar helper function and turns the value of the specified key to its uppercase value. So, for `message: 'hello woRld'`, if we write `{{uppercase message}}`, we'll end up with `HELLO WORLD`|
| `{{titlecase key}}` | This helps you use the `titlecase` handlebar helper function and turns the value of the specified key to its titlecase value. So, for `message: 'hEllo wOrLD'`, if we write `{{titlecase message}}`, we'll end up with `Hello World`|

## Use-cases and examples

By combining the functions and properties above, we can get some powerful results. Let's take a look at some scenarios and how you can achieve them:

1. Suppose you're writing a social media app and you want your users to be notified once every 8 hrs as to how many comments they received in the last 8 hours.<br/><br/>To achieve this, you can create a workflow with a digest node and set the duration to 8 hours. Then in the workflow editor, you can use the following:
`{{step.total_count}} liked your photo!`

:::info
Note: The `step.total_count` gives the total number of events in the digest period. Be careful when using this if you have multiple types of notifications being triggered as it will just output the total number of notifications triggered during the digest period.
:::
2. Ternary operator use-case - If you want to use ternary operator in the template, you can do so like this:
`{{#equals array.length 2}} do something {{else}} do something else {{/equals}}`. <br/><br/>Here, if the `array.length` is `2`, `do something` block will be executed and if it isn't then `do something else` will be executed.<br/><br/> For example, <br/>
`{{#equals unreadMessages.length 2}}`<br/>`You have 2 new messages.`<br/>`{{else}}`<br/>`You have {{unreadMessageslength}} new messages.`<br/>`{{/equals}}`<br/><br/>
3. If you've an array of objects in your payload and you want to iterate over them and send dynamic notifications, you can do so like this:<br/><br/>
Payload data:<br/>`const payload = {`
`array: [`<br/>
`{`
`name: 'John',`
`score: 8,`
`},`
`{`
`name: 'Emily',`
`score: 6,`
`},`
`{`
`name: 'Michael',`
`score: 9,`
`},`
`],`
`};`<br/><br/>
Template:
`{{#each array}}`
`Hi {{name}}! You have {{score}} points.`
`{{/each}}`

## Next steps

To learn more about Novu's digest engine and how to use it, check out [Novu Digest Engine](https://docs.novu.co/platform/digest).
2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@novu/docs",
"version": "0.17.2",
"version": "0.18.0",
"private": true,
"scripts": {
"docusaurus": "docusaurus",
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
"message": "chore(release): publish - ci skip"
}
},
"version": "0.17.2"
"version": "0.18.0"
}
4 changes: 2 additions & 2 deletions libs/dal/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@novu/dal",
"version": "0.17.2",
"version": "0.18.0",
"description": "",
"private": true,
"scripts": {
Expand All @@ -24,7 +24,7 @@
"@aws-sdk/client-s3": "^3.382.0",
"@aws-sdk/s3-request-presigner": "^3.382.0",
"@faker-js/faker": "^6.0.0",
"@novu/shared": "^0.17.2",
"@novu/shared": "^0.18.0",
"@sendgrid/mail": "^7.4.2",
"JSONStream": "^1.3.5",
"agenda": "^4.0.1",
Expand Down
4 changes: 2 additions & 2 deletions libs/embed/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@novu/embed",
"version": "0.17.2",
"version": "0.18.0",
"private": true,
"description": "",
"keywords": [],
Expand Down Expand Up @@ -127,7 +127,7 @@
"typescript": "4.9.5"
},
"dependencies": {
"@novu/notification-center": "^0.17.2",
"@novu/notification-center": "^0.18.0",
"@types/iframe-resizer": "^3.5.8",
"iframe-resizer": "^4.3.1"
}
Expand Down
2 changes: 1 addition & 1 deletion libs/shared/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@novu/shared",
"version": "0.17.2",
"version": "0.18.0",
"description": "",
"scripts": {
"start": "npm run start:dev",
Expand Down
6 changes: 3 additions & 3 deletions libs/testing/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@novu/testing",
"version": "0.17.2",
"version": "0.18.0",
"description": "",
"private": true,
"scripts": {
Expand All @@ -22,8 +22,8 @@
"types": "dist/index.d.ts",
"dependencies": {
"@faker-js/faker": "^6.0.0",
"@novu/dal": "^0.17.2",
"@novu/shared": "^0.17.2",
"@novu/dal": "^0.18.0",
"@novu/shared": "^0.18.0",
"JSONStream": "^1.3.5",
"async": "^3.2.0",
"axios": "^1.3.3",
Expand Down
Loading

3 comments on commit 61299b2

@github-actions
Copy link

Choose a reason for hiding this comment

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

@github-actions
Copy link

Choose a reason for hiding this comment

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

@github-actions
Copy link

Choose a reason for hiding this comment

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

Please sign in to comment.