Skip to content

Commit

Permalink
Merge branch 'next' into headless_api_issue_fix
Browse files Browse the repository at this point in the history
  • Loading branch information
BiswaViraj authored Jan 5, 2024
2 parents 9edc749 + 1f1f78f commit f0575c5
Show file tree
Hide file tree
Showing 27 changed files with 372 additions and 3 deletions.
1 change: 1 addition & 0 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,7 @@
"Stdev",
"openapi",
"headerapikey",
"isend"
],
"flagWords": [],
"patterns": [
Expand Down
4 changes: 2 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
"editor.wordWrap": "wordWrapColumn",
"editor.wordWrapColumn": 120,
"editor.codeActionsOnSave": {
"source.fixAll": true
"source.fixAll": "explicit"
},
"cSpell.words": ["mantine"],
"vsicons.presets.nestjs": true,
"[markdown]": {
"editor.defaultFormatter": "DavidAnson.vscode-markdownlint"
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
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.
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 @@ -25,6 +25,7 @@ import {
messagebirdConfig,
azureSmsConfig,
bulkSmsConfig,
iSendSmsConfig,
} from '../credentials';
import { SmsProviderIdEnum } from '../provider.enum';

Expand Down Expand Up @@ -136,6 +137,14 @@ export const smsProviders: IProviderConfig[] = [
docReference: 'https://www.bulksms.com/developer/json/v1/',
logoFileName: { light: 'bulk-sms.png', dark: 'bulk-sms.png' },
},
{
id: SmsProviderIdEnum.ISendSms,
displayName: 'iSend SMS',
channel: ChannelTypeEnum.SMS,
credentials: iSendSmsConfig,
docReference: 'https://send.com.ly/developers/docs',
logoFileName: { light: 'isend-sms.png', dark: 'isend-sms.png' },
},
{
id: SmsProviderIdEnum.Clickatell,
displayName: 'clickatell',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,33 @@ export const bulkSmsConfig: IConfigCredentials[] = [
},
];

export const iSendSmsConfig: IConfigCredentials[] = [
{
key: CredentialsKeyEnum.ApiToken,
displayName: 'API Token',
type: 'string',
required: true,
},
{
key: CredentialsKeyEnum.From,
displayName: 'Default Sender ID',
type: 'string',
required: false,
},
{
key: CredentialsKeyEnum.ContentType,
displayName: 'Content Type',
type: 'dropdown',
required: false,
value: null,
dropdown: [
{ name: 'Default', value: null },
{ name: 'Unicode', value: 'unicode' },
{ name: 'Plain', value: 'plain' },
],
},
];

export const clickatellConfig: IConfigCredentials[] = [
{
key: CredentialsKeyEnum.ApiKey,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { CredentialsKeyEnum } from '../provider.enum';

export const secureCredentials: CredentialsKeyEnum[] = [
CredentialsKeyEnum.ApiKey,
CredentialsKeyEnum.ApiToken,
CredentialsKeyEnum.SecretKey,
CredentialsKeyEnum.Token,
CredentialsKeyEnum.Password,
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 @@ -15,6 +15,7 @@ export enum CredentialsKeyEnum {
Token = 'token',
From = 'from',
SenderName = 'senderName',
ContentType = 'contentType',
ApplicationId = 'applicationId',
ClientId = 'clientId',
ProjectName = 'projectName',
Expand Down Expand Up @@ -82,6 +83,7 @@ export enum SmsProviderIdEnum {
Infobip = 'infobip-sms',
BurstSms = 'burst-sms',
BulkSms = 'bulk-sms',
ISendSms = 'isend-sms',
Clickatell = 'clickatell',
FortySixElks = 'forty-six-elks',
Kannel = 'kannel',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export interface ICredentials {
token?: string;
from?: string;
senderName?: string;
contentType?: string;
applicationId?: string;
clientId?: string;
projectName?: string;
Expand Down
1 change: 1 addition & 0 deletions packages/application-generic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"@novu/bandwidth": "^0.22.0",
"@novu/braze": "^0.22.0",
"@novu/bulk-sms": "^0.22.0",
"@novu/isend-sms": "^0.22.0",
"@novu/burst-sms": "^0.22.0",
"@novu/clickatell": "^0.22.0",
"@novu/clicksend": "^0.22.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ export * from './messagebird.handler';
export * from './azure-sms.handler';
export * from './bulk-sms.handler';
export * from './nexmo.handler';
export * from './isend-sms.handler';
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { ChannelTypeEnum, ICredentials } from '@novu/shared';
import { ISendSmsProvider } from '@novu/isend-sms';
import { BaseSmsHandler } from './base.handler';

export class ISendSmsHandler extends BaseSmsHandler {
constructor() {
super('isend-sms', ChannelTypeEnum.SMS);
}

buildProvider(credentials: ICredentials) {
const config: {
apiToken: string;
} = {
apiToken: credentials.apiToken ?? '',
...credentials,
};

this.provider = new ISendSmsProvider(config);
}
}
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 @@ -26,6 +26,7 @@ import {
AzureSmsHandler,
NovuSmsHandler,
NexmoHandler,
ISendSmsHandler,
} from './handlers';

export class SmsFactory implements ISmsFactory {
Expand Down Expand Up @@ -55,6 +56,7 @@ export class SmsFactory implements ISmsFactory {
new AzureSmsHandler(),
new NovuSmsHandler(),
new NexmoHandler(),
new ISendSmsHandler(),
];

getHandler(integration: IntegrationEntity) {
Expand Down
48 changes: 47 additions & 1 deletion 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/isend-sms/.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/isend-sms/.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/isend-sms/.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
20 changes: 20 additions & 0 deletions providers/isend-sms/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Novu iSend SMS Provider

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

## Usage

```javascript
import { ISendSmsProvider } from '@novu/isend-sms';

const provider = new ISendSmsProvider({
// (Required) Get an API token from https://send.com.ly/
apiToken: process.env.ISENDSMS_API_TOKEN,

// (Optional) The sender id provided by iSend
from: process.env.ISENDSMS_SENDER_ID,

// (Optional) Either 'unicode' or 'plain'
contentType: process.env.ISENDSMS_MSG_TYPE,
});
```
8 changes: 8 additions & 0 deletions providers/isend-sms/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
moduleNameMapper: {
axios: 'axios/dist/node/axios.cjs',
},
};
78 changes: 78 additions & 0 deletions providers/isend-sms/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{
"name": "@novu/isend-sms",
"version": "0.22.0",
"description": "A isend-sms 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.22.0",
"axios": "^1.6.0"
},
"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/isend-sms/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './lib/isend-sms.provider';
32 changes: 32 additions & 0 deletions providers/isend-sms/src/lib/isend-sms.provider.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { ISendSmsProvider } from './isend-sms.provider';

const mockConfig = {
apiToken: 'test-key',
};

const mockBulkSMSMessage = {
to: '2348055372961',
content: 'sms content',
from: '45483533',
};

test('should trigger isend-sms library correctly', async () => {
const smsProvider = new ISendSmsProvider(mockConfig);
const spy = jest
.spyOn(smsProvider, 'sendMessage')
.mockImplementation(async () => {
return {
id: '67890-90q8',
date: new Date().toISOString(),
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} as any;
});

await smsProvider.sendMessage(mockBulkSMSMessage);
expect(spy).toHaveBeenCalled();
expect(spy).toHaveBeenCalledWith({
to: '2348055372961',
content: 'sms content',
from: '45483533',
});
});
Loading

0 comments on commit f0575c5

Please sign in to comment.