Skip to content

Commit

Permalink
Merge branch 'next' into feature/update-organisation
Browse files Browse the repository at this point in the history
  • Loading branch information
scopsy authored Feb 8, 2023
2 parents 60eb79a + d08f3be commit dbcccb1
Show file tree
Hide file tree
Showing 147 changed files with 6,345 additions and 12,355 deletions.
3 changes: 2 additions & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,8 @@
"codesee",
"ehlo",
"logrocket",
"backoff"
"backoff",
"isequal"
],
"flagWords": [],
"patterns": [
Expand Down
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ RUN . /etc/os-release \
# RUN su node -c "source /usr/local/share/nvm/nvm.sh && nvm install ${EXTRA_NODE_VERSION}"

# [Optional] Uncomment if you want to install more global node modules
RUN su node -c "npm install -g pnpm@7.5.0"
RUN su node -c "npm install -g pnpm@7.26.3"



2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = {
'airbnb-typescript',
'plugin:import/typescript',
'plugin:@typescript-eslint/recommended',
'prettier/@typescript-eslint',
'prettier',
'plugin:prettier/recommended',
'plugin:promise/recommended',
'plugin:@cspell/recommended',
Expand Down
5 changes: 2 additions & 3 deletions .github/actions/setup-project/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,17 @@ runs:
node-version: '16.15.1'

- name: 💵 Start Redis
uses: supercharge/redis-github-action@1.2.0
uses: supercharge/redis-github-action@1.4.0

- name: 📚 Start MongoDB
uses: supercharge/mongodb-github-action@1.3.0
uses: supercharge/mongodb-github-action@v1.8.0
with:
mongodb-version: 4.2.8

- uses: pnpm/action-setup@v2
name: 🛟 Install pnpm
id: pnpm-install
with:
version: 7.5.0
run_install: false

- name: ⛏️ Get pnpm store directory
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/prod-deploy-inbound-mail.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,16 @@ jobs:
with:
node-version: '16.15.1'
- name: Start Redis
uses: supercharge/redis-github-action@1.2.0
uses: supercharge/redis-github-action@1.4.0

- uses: pnpm/action-setup@v2.0.1
- uses: pnpm/action-setup@v2.2.4
with:
version: 7.5.0
run_install: false

- uses: pnpm/action-setup@v2
name: Install pnpm
id: pnpm-install
with:
version: 7.5.0
run_install: false

- name: Get pnpm store directory
Expand Down
2 changes: 1 addition & 1 deletion .gitpod.dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM gitpod/workspace-mongodb

RUN sudo apt-get update && sudo apt-get install -y redis-server && sudo rm -rf /var/lib/apt/lists/*
RUN npm install -g pnpm@7.5.0
RUN npm install -g pnpm@7.26.3
3 changes: 1 addition & 2 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 3 additions & 7 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
{
"cSpell.userWords": [], // only use words from .cspell.json
"cSpell.userWords": [],
"cSpell.enabled": true,
"typescript.tsdk": "node_modules/typescript/lib",
"typescript.enablePromptUseWorkspaceTsdk": true,
"npm.packageManager": "yarn",
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
"editor.formatOnSave": true,
"eslint.format.enable": true,
"editor.tabSize": 2,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"files.insertFinalNewline": true,
"files.trimFinalNewlines": true,
"css.validate": false,
"editor.wordWrap": "wordWrapColumn",
"editor.wordWrapColumn": 120
"editor.wordWrapColumn": 120,
"editor.codeActionsOnSave": {
"source.fixAll": true
},
"cSpell.words": [
"mantine"
]
"cSpell.words": ["mantine"]
}
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
<div align="center">
<a href="https://novu.co/polishing" target="_blank">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://user-images.githubusercontent.com/100117126/216938999-e49784fc-f5a9-43d3-8430-f33c1be1a38a.jpeg">
<img width="100%" src="https://user-images.githubusercontent.com/100117126/216939116-d5f8f4d2-6c7c-4165-a509-0844909dd9eb.jpeg" width="280" alt="Bar"/>
</picture>
</a>
</div>

</br>
</br>

Expand Down
4 changes: 2 additions & 2 deletions _templates/provider/new/package.ejs.t
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@
"open-cli": "^6.0.1",
"prettier": "^2.1.1",
"ts-jest": "^27.0.5",
"ts-node": "^9.0.0",
"ts-node": "~10.9.1",
"typedoc": "^0.19.0",
"typescript": "4.6.2",
"typescript": "4.9.5",
"rimraf": "^3.0.2"
},
"files": [
Expand Down
2 changes: 1 addition & 1 deletion apps/api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM nikolaik/python-nodejs:python3.10-nodejs16-alpine as dev_base

RUN npm i pm2 -g
RUN npm --no-update-notifier --no-fund --global install pnpm@7.5.0
RUN npm --no-update-notifier --no-fund --global install pnpm@7.26.3
RUN pnpm --version

WORKDIR /usr/src/app
Expand Down
8 changes: 4 additions & 4 deletions apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
"@types/bcrypt": "^3.0.0",
"@types/bull": "^3.15.8",
"@types/chai": "^4.2.11",
"@types/express": "4.17.16",
"@types/express": "4.17.17",
"@types/mocha": "^8.0.1",
"@types/node": "^14.6.0",
"@types/passport-github": "^1.1.5",
Expand All @@ -133,10 +133,10 @@
"mocha": "^8.1.1",
"nodemon": "^2.0.3",
"sinon": "^9.2.4",
"ts-loader": "9.2.8",
"ts-node": "^9.0.0",
"ts-loader": "~9.4.0",
"ts-node": "~10.9.1",
"tsconfig-paths": "3.14.1",
"typescript": "4.3.5"
"typescript": "4.9.5"
},
"lint-staged": {
"*.{js,jsx,ts,tsx}": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export class PromoteMessageTemplateChange {
title: newItem.title,
cta: newItem.cta,
active: newItem.active,
actor: newItem.actor,
_parentId: newItem._id,
_feedId: feed?._id,
_layoutId: layout?._id,
Expand All @@ -67,6 +68,7 @@ export class PromoteMessageTemplateChange {
title: newItem.title,
cta: newItem.cta,
active: newItem.active,
actor: newItem.actor,
_feedId: feed?._id,
_layoutId: layout?._id,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,34 @@ describe('Compile E-mail Template', function () {
expect(subject).to.equal('A title for Header Test');
});

it('should apply subject variable if provided', async function () {
const subjectText = 'Novu Test';
const { html, subject } = await useCase.execute(
CompileEmailTemplateCommand.create({
organizationId: session.organization._id,
environmentId: session.environment._id,
layoutId: null,
preheader: null,
content: [
{
content: '<p>{{subject}}</p>',
type: EmailBlockTypeEnum.TEXT,
},
],
payload: { subject: subjectText },
userId: session.user._id,
contentType: 'editor',
subject: '{{subject}}',
})
);

expect(html).to.contain('<!DOCTYPE html');
expect(html).to.not.contain('{{subject}}');
expect(html).to.contain(`<p>${subjectText}</p>`);

expect(subject).to.equal(subjectText);
});

describe('Backwards compatability', function () {
it('should compile e-mail template for custom html without layouts attached for backwards compatability', async function () {
const { html, subject } = await useCase.execute(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ export class CompileEmailTemplate {

const payload = {
...command.payload,
subject: command.subject,
preheader,
blocks: [],
branding: {
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/app/events/e2e/delay-events.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ describe('Trigger event - Delay triggered events - /v1/events/trigger (POST)', f
const diff = differenceInMilliseconds(new Date(delayedJob.payload.sendAt), new Date(delayedJob?.updatedAt));

const delay = await workflowQueueService.queue.getDelayed();
expect(delay[0].opts.delay).to.approximately(diff, 500);
expect(delay[0].opts.delay).to.approximately(diff, 1000);
});

it('should not include delayed event in digested sent message', async function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,16 @@ export class CalculateLimitNovuIntegration {
return;
}

const messagesCount = await this.messageRepository.count({
channel: command.channelType,
_organizationId: command.organizationId,
providerId,
createdAt: { $gte: startOfMonth(new Date()), $lte: endOfMonth(new Date()) },
});
const messagesCount = await this.messageRepository.count(
{
channel: command.channelType,
_organizationId: command.organizationId,
_environmentId: command.environmentId,
providerId,
createdAt: { $gte: startOfMonth(new Date()), $lte: endOfMonth(new Date()) },
},
CalculateLimitNovuIntegration.MAX_NOVU_INTEGRATION_MAIL_REQUESTS
);

return {
limit: CalculateLimitNovuIntegration.MAX_NOVU_INTEGRATION_MAIL_REQUESTS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ describe('Get Novu Integration', function () {
sinon.assert.calledWith(stub, {
channel: ChannelTypeEnum.EMAIL,
_organizationId: session.organization._id,
_environmentId: session.environment._id,
providerId: EmailProviderIdEnum.Novu,
createdAt: { $gte: startOfMonth(new Date()), $lte: endOfMonth(new Date()) },
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { encryptCredentials } from '../../../shared/services/encryption';
import { CheckIntegration } from '../check-integration/check-integration.usecase';
import { CheckIntegrationCommand } from '../check-integration/check-integration.command';
import { CacheKeyPrefixEnum, InvalidateCacheService } from '../../../shared/services/cache';
import { ChannelTypeEnum } from '@novu/shared';

@Injectable()
export class UpdateIntegration {
Expand Down Expand Up @@ -64,7 +65,7 @@ export class UpdateIntegration {
}
);

if (command.active) {
if (command.active && ![ChannelTypeEnum.CHAT, ChannelTypeEnum.PUSH].includes(existingIntegration.channel)) {
await this.deactivateSimilarChannelIntegrations.execute({
environmentId: command.environmentId,
organizationId: command.organizationId,
Expand Down
8 changes: 5 additions & 3 deletions apps/api/src/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import { RolesGuard } from './app/auth/framework/roles.guard';
import { SubscriberRouteGuard } from './app/auth/framework/subscriber-route.guard';
import { validateEnv } from './config/env-validator';

const extendedBodySizeRoutes = ['/v1/events', '/v1/notification-templates', '/v1/layouts'];

if (process.env.SENTRY_DSN) {
Sentry.init({
dsn: process.env.SENTRY_DSN,
Expand All @@ -37,7 +39,7 @@ if (process.env.SENTRY_DSN) {
validateEnv();

export async function bootstrap(expressApp?): Promise<INestApplication> {
let app;
let app: INestApplication;
if (expressApp) {
app = await NestFactory.create(AppModule, new ExpressAdapter(expressApp));
} else {
Expand Down Expand Up @@ -67,8 +69,8 @@ export async function bootstrap(expressApp?): Promise<INestApplication> {
app.useGlobalGuards(new RolesGuard(app.get(Reflector)));
app.useGlobalGuards(new SubscriberRouteGuard(app.get(Reflector)));

app.use('/v1/events/trigger', bodyParser.json({ limit: '20mb' }));
app.use('/v1/events/trigger', bodyParser.urlencoded({ limit: '20mb', extended: true }));
app.use(extendedBodySizeRoutes, bodyParser.json({ limit: '20mb' }));
app.use(extendedBodySizeRoutes, bodyParser.urlencoded({ limit: '20mb', extended: true }));

app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
Expand Down
2 changes: 1 addition & 1 deletion apps/inbound-mail/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM nikolaik/python-nodejs:python3.10-nodejs16-alpine as dev_base

RUN npm i pm2 -g
RUN npm --no-update-notifier --no-fund --global install pnpm@7.5.0
RUN npm --no-update-notifier --no-fund --global install pnpm@7.26.3
RUN pnpm --version

WORKDIR /usr/src/app
Expand Down
6 changes: 3 additions & 3 deletions apps/inbound-mail/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@
"nodemon": "^2.0.7",
"prettier": "^2.1.2",
"ts-jest": "^27.0.7",
"ts-loader": "^8.0.8",
"ts-node": "^9.0.0",
"ts-loader": "~9.4.0",
"ts-node": "~10.9.1",
"tsconfig-paths": "^3.9.0",
"typescript": "4.3.5"
"typescript": "4.9.5"
}
}
2 changes: 1 addition & 1 deletion apps/web/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM nikolaik/python-nodejs:python3.10-nodejs16-alpine
WORKDIR /usr/src/app

RUN apk add --no-cache bash
RUN npm install -g pnpm@7.5.0 --loglevel notice
RUN npm install -g pnpm@7.26.3 --loglevel notice

COPY .npmrc .
COPY package.json .
Expand Down
2 changes: 1 addition & 1 deletion apps/web/cypress/tests/changes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ function createNotification() {

cy.getByTestId('emailSubject').type('this is email subject');

cy.getByTestId('submit-btn').click();
cy.getByTestId('notification-template-submit-btn').click();
cy.waitForNetworkIdle(500);
cy.getByTestId('trigger-snippet-btn').click();
}
Expand Down
Loading

0 comments on commit dbcccb1

Please sign in to comment.