Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Added MessageBird SMS client #4687

Merged
merged 5 commits into from
Oct 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,9 @@
"ryver",
"idempotency",
"IDEMPOTENCY",
"Idempotency"
"Idempotency",
"messagebird",
"Datetime"
],
"flagWords": [],
"patterns": [
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions libs/shared/src/consts/providers/channels/sms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
genericSmsConfig,
clickSendConfig,
bandwidthConfig,
messagebirdConfig,
} from '../credentials';
import { SmsProviderIdEnum } from '../provider.enum';

Expand Down Expand Up @@ -76,6 +77,14 @@ export const smsProviders: IProviderConfig[] = [
docReference: 'https://docs.novu.co/channels-and-providers/sms/telnyx',
logoFileName: { light: 'telnyx.png', dark: 'telnyx.png' },
},
{
id: SmsProviderIdEnum.MessageBird,
displayName: 'MessageBird',
channel: ChannelTypeEnum.SMS,
credentials: messagebirdConfig,
docReference: 'https://developers.messagebird.com/quickstarts/sms-overview/',
logoFileName: { light: 'messagebird.png', dark: 'messagebird.png' },
},
{
id: SmsProviderIdEnum.Twilio,
displayName: 'Twilio',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,16 @@ export const twilioConfig: IConfigCredentials[] = [
...smsConfigBase,
];

export const messagebirdConfig: IConfigCredentials[] = [
{
key: CredentialsKeyEnum.AccessKey,
displayName: 'Access key',
type: 'string',
required: true,
},
...smsConfigBase,
];

export const slackConfig: IConfigCredentials[] = [
{
key: CredentialsKeyEnum.ApplicationId,
Expand Down
2 changes: 2 additions & 0 deletions libs/shared/src/consts/providers/provider.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export enum CredentialsKeyEnum {
DatePath = 'datePath',
AuthenticateByToken = 'authenticateByToken',
AuthenticationTokenKey = 'authenticationTokenKey',
AccessKey = 'accessKey',
}

export enum EmailProviderIdEnum {
Expand Down Expand Up @@ -81,6 +82,7 @@ export enum SmsProviderIdEnum {
GenericSms = 'generic-sms',
Clicksend = 'clicksend',
Bandwidth = 'bandwidth',
MessageBird = 'messagebird',
}

export enum ChatProviderIdEnum {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ export interface ICredentials {
datePath?: string;
authenticateByToken?: boolean;
authenticationTokenKey?: string;
accessKey?: string;
}
1 change: 1 addition & 0 deletions packages/application-generic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
"@novu/mandrill": "^0.21.0",
"@novu/maqsam": "^0.21.0",
"@novu/mattermost": "^0.21.0",
"@novu/messagebird": "^0.21.0",
"@novu/ms-teams": "^0.21.0",
"@novu/netcore": "^0.21.0",
"@novu/nodemailer": "^0.21.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ export * from './clicksend.handler';
export * from './bandwidth.handler';
export * from './novu.handler';
export * from './generic-sms.handler';
export * from './messagebird.handler';
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { MessageBirdSmsProvider } from '@novu/messagebird';
import { ChannelTypeEnum, ICredentials } from '@novu/shared';
import { BaseSmsHandler } from './base.handler';

export class MessageBirdHandler extends BaseSmsHandler {
constructor() {
super('messagebird', ChannelTypeEnum.SMS);
}
buildProvider(credentials: ICredentials) {
this.provider = new MessageBirdSmsProvider({
access_key: credentials.accessKey,
});
}
}
2 changes: 2 additions & 0 deletions packages/application-generic/src/factories/sms/sms.factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
BandwidthHandler,
NovuSmsHandler,
GenericSmsHandler,
MessageBirdHandler,
} from './handlers';

export class SmsFactory implements ISmsFactory {
Expand All @@ -47,6 +48,7 @@ export class SmsFactory implements ISmsFactory {
new BandwidthHandler(),
new NovuSmsHandler(),
new GenericSmsHandler(),
new MessageBirdHandler(),
];

getHandler(integration: IntegrationEntity) {
Expand Down
66 changes: 61 additions & 5 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/messagebird/.czrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"path": "cz-conventional-changelog"
}
3 changes: 3 additions & 0 deletions providers/messagebird/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "../../.eslintrc.js"
}
9 changes: 9 additions & 0 deletions providers/messagebird/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.idea/*
.nyc_output
build
node_modules
test
src/**.js
coverage
*.log
package-lock.json
13 changes: 13 additions & 0 deletions providers/messagebird/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Novu Messagebird Provider

A Messagebird sms provider library for [@novu/node](https://github.com/novuhq/novu)

## Usage

```javascript
import { MessageBirdProvider } from '@novu/messagebird';

const provider = new MailgunEmailProvider({
access_key: process.env.MESSAGEBIRD_ACCESS_KEY,
});
```
5 changes: 5 additions & 0 deletions providers/messagebird/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
};
78 changes: 78 additions & 0 deletions providers/messagebird/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{
"name": "@novu/messagebird",
"version": "0.21.0",
"description": "A messagebird wrapper for novu",
"main": "build/main/index.js",
"typings": "build/main/index.d.ts",
"module": "build/module/index.js",
"private": false,
"repository": "https://github.com/novuhq/novu",
"license": "MIT",
"keywords": [],
"scripts": {
"prebuild": "rimraf build",
"build": "run-p build:*",
"build:main": "tsc -p tsconfig.json",
"build:module": "tsc -p tsconfig.module.json",
"fix": "run-s fix:*",
"fix:prettier": "prettier \"src/**/*.ts\" --write",
"fix:lint": "eslint src --ext .ts --fix",
"test": "run-s test:*",
"lint": "eslint src --ext .ts",
"test:unit": "jest src",
"watch:build": "tsc -p tsconfig.json -w",
"watch:test": "jest src --watch",
"reset-hard": "git clean -dfx && git reset --hard && yarn",
"prepare-release": "run-s reset-hard test"
},
"publishConfig": {
"access": "public"
},
"dependencies": {
"@novu/stateless": "0.16.3",
"messagebird": "^4.0.1"
},
"devDependencies": {
"@istanbuljs/nyc-config-typescript": "~1.0.1",
"@types/jest": "~27.5.2",
"cspell": "~6.19.2",
"jest": "~27.5.1",
"npm-run-all": "^4.1.5",
"nyc": "~15.1.0",
"prettier": "~2.8.0",
"rimraf": "~3.0.2",
"ts-jest": "~27.1.5",
"ts-node": "~10.9.1",
"typescript": "4.9.5"
},
"files": [
"build/main",
"build/module",
"!**/*.spec.*",
"!**/*.json",
"CHANGELOG.md",
"LICENSE",
"README.md"
],
"ava": {
"failFast": true,
"timeout": "60s",
"typescript": {
"rewritePaths": {
"src/": "build/main/"
}
},
"files": [
"!build/module/**"
]
},
"prettier": {
"singleQuote": true
},
"nyc": {
"extends": "@istanbuljs/nyc-config-typescript",
"exclude": [
"**/*.spec.js"
]
}
}
1 change: 1 addition & 0 deletions providers/messagebird/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './lib/messagebird.provider';
Loading
Loading