forked from novuhq/novu
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'next' into headless_api_issue_fix
- Loading branch information
Showing
27 changed files
with
372 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -544,6 +544,7 @@ | |
"Stdev", | ||
"openapi", | ||
"headerapikey", | ||
"isend" | ||
], | ||
"flagWords": [], | ||
"patterns": [ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
packages/application-generic/src/factories/sms/handlers/isend-sms.handler.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"path": "cz-conventional-changelog" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "../../.eslintrc.js" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './lib/isend-sms.provider'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | ||
}); | ||
}); |
Oops, something went wrong.