Skip to content

Commit

Permalink
Merge branch 'next' into inf-291-nc-artifacts
Browse files Browse the repository at this point in the history
  • Loading branch information
AliaksandrRyzhou authored Mar 7, 2024
2 parents 74e0936 + eed84f9 commit 2f17d30
Show file tree
Hide file tree
Showing 8 changed files with 170 additions and 26 deletions.
1 change: 1 addition & 0 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,7 @@
"restapi",
"ringcentral",
"reshard",
"userid",
"endgroup",
"aliyun",
"azcopy",
Expand Down
2 changes: 1 addition & 1 deletion .source
65 changes: 65 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ With Novu, you can create custom workflows and define conditions for each channe
## 📚 Table Of Contents

- [Getting Started](https://github.com/novuhq/novu#-getting-started)
- [GitOps & React Email Integration](https://github.com/novuhq/novu#-gitops)
- [Embeddable notification center](https://github.com/novuhq/novu#embeddable-notification-center)
- [Providers](https://github.com/novuhq/novu#providers)
- [Email](https://github.com/novuhq/novu#-email)
Expand Down Expand Up @@ -135,6 +136,70 @@ await novu.trigger('<TRIGGER_NAME>', {
});
```

## GitOps & React Email Integration
Create notification workflows right from your IDE and integrate with MJML/React Email/Maizzle and others

- Fully managed GitOps Flow, deployed from your CI
- Local Dev Studio to develop and debug workflows in your IDE
- React Email/Maizzle/MJML integrations
- Runs in your VPC
- Debug cloud triggers in your IDE
- Type safety with your favorite programming language
- Define workflow and step validations with Zod or JSON Schema
- Modify content and behavior via Web management input panel

[Request Early Access](https://novu.co/novu-echo-coming-soon/?utm_campaign=github)

```ts

client.workflow('comment-on-post', async ({step, subscriber}) => {
const inAppResponse = await step.inApp('in-app-step', async (inputs) => {
return {
// body: renderReactComponent(inputs)
};
}, {
inputs: {
// ...JSON Schema or ZOD/Ajv/Class Validators definition
}
});

// Novu Worker Engine will manage the state and durability of each step in isolation
const {digestedEvents} = await step.digest('1 day');

await step.email('email-step', async () => {
return {
subject: 'E-mail Subject',
body: renderReactEmail(<ReactEmailComponent events={digestedEvents} />);
}
}, {
// Step-level inputs defined in code and controlled in the novu Cloud UI by a Non-Technical Team member
inputs: {
// ...JSON Schema
},
providers: {
sendgrid: async (inputs) => {
// Echo runs as part of your application, so you have access to your database or resources

return {
to: email,
ipPoolName: 'custom-pool'
};
}
},
skip: () => {
// Write custom skip logic
return inAppResponse.seen || subscriber.isOnline;
}
});
// Define your workflow trigger payload using json schema and custom validation;
}, {
dataSchema: {
// ...JSON Schema
}
});

```

## Embeddable Notification Center

Using the Novu API and admin panel, you can easily add a real-time notification center to your web app without building it yourself. You can use our [React](https://docs.novu.co/notification-center/client/react/get-started) / [Vue](https://docs.novu.co/notification-center/client/vue) / [Angular](https://docs.novu.co/notification-center/client/angular) components or an [iframe embed](https://docs.novu.co/notification-center/client/iframe), as well as a [Web component](https://docs.novu.co/notification-center/client/web-component).
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { UserSession } from '@novu/testing';
import { expect } from 'chai';
import { OrganizationRepository } from '@novu/dal';

describe('Update default locale and add new translations - /translations/language (PATCH)', async () => {
let session: UserSession;
const organizationRepository = new OrganizationRepository();

before(async () => {
session = new UserSession();
await session.initialize();
await session.testAgent.put(`/v1/organizations/language`).send({
locale: 'en_US',
});
});

it('should update default locale and add that locale to groups', async () => {
await session.testAgent.post(`/v1/translations/groups`).send({
name: 'test',
identifier: 'test',
locales: ['en_US', 'sv_SE'],
});

await session.applyChanges({
enabled: false,
});

await session.testAgent.patch(`/v1/translations/language`).send({
locale: 'en_GB',
});

const org = await organizationRepository.findById(session.organization._id);
expect(org?.defaultLocale).to.be.equal('en_GB');

const result = await session.testAgent.get(`/v1/translations/groups/test`).send();
let group = result.body.data;

let locales = group.translations.map((t) => t.isoLanguage);

expect(locales).to.deep.equal(['en_US', 'sv_SE', 'en_GB']);

await session.applyChanges({
enabled: false,
});
await session.switchToProdEnvironment();

const data = await session.testAgent.get(`/v1/translations/groups/test`).send();
group = data.body.data;
locales = group.translations.map((t) => t.isoLanguage);
expect(locales).to.deep.equal(['en_US', 'sv_SE', 'en_GB']);
});
});
56 changes: 42 additions & 14 deletions pnpm-lock.yaml

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

3 changes: 3 additions & 0 deletions providers/gupshup/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ module.exports = {
'^.+\\.js$': 'babel-jest',
},
transformIgnorePatterns: ['<rootDir>/node_modules/'],
moduleNameMapper: {
axios: 'axios/dist/node/axios.cjs',
}
};
3 changes: 2 additions & 1 deletion providers/gupshup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
"node": ">=10"
},
"dependencies": {
"@novu/stateless": "^0.24.0",
"@novu/stateless": "^0.23.1",
"axios": "^1.6.7",
"node-fetch": "^3.2.10"
},
"devDependencies": {
Expand Down
14 changes: 4 additions & 10 deletions providers/gupshup/src/lib/gupshup.provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
ISmsOptions,
ISmsProvider,
} from '@novu/stateless';
import axios from 'axios';

if (!globalThis.fetch) {
// eslint-disable-next-line global-require
Expand Down Expand Up @@ -33,7 +34,7 @@ export class GupshupSmsProvider implements ISmsProvider {
method: 'sendMessage',
format: 'text',
v: '1.1',
userId: this.config.userId,
userid: this.config.userId,
password: this.config.password,
...(options.customData?.principalEntityId && {
principalEntityId: options.customData?.principalEntityId,
Expand All @@ -43,16 +44,9 @@ export class GupshupSmsProvider implements ISmsProvider {
}),
};

const opts = {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
body: new URLSearchParams(params),
};
const response = await axios.post(GupshupSmsProvider.BASE_URL, params);

const response = await fetch(GupshupSmsProvider.BASE_URL, opts);
const body = await response.text();
const body = response.data;
const result = body.split(' | ');

if (result[0] === 'error') {
Expand Down

0 comments on commit 2f17d30

Please sign in to comment.