-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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 eazy sms #5393
Merged
Merged
Feat eazy sms #5393
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
7bf0ecd
feat: eazy sms provider
sr-26 f149ac3
feat: eazy sms provider
sr-26 4c51f2f
feat: eazy sms provider
sr-26 1ee283b
Update providers/eazy-sms/README.md
sr-26 292be87
feat: eazy sms provider
sr-26 c84851a
fix: added eazy sms in sort list
sr-26 1fab824
Merge branch 'next' into feat-eazy-sms
BiswaViraj e4e6fa1
Merge branch 'next' into feat-eazy-sms
BiswaViraj 6b1003a
fix: added eazy in cspell
sr-26 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions
14
apps/web/public/static/images/providers/dark/square/eazy-sms.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions
14
apps/web/public/static/images/providers/light/eazy-sms.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions
14
apps/web/public/static/images/providers/light/square/eazy-sms.svg
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,4 +42,5 @@ export interface ICredentials { | |
imageUrl?: string; | ||
state?: string; | ||
externalLink?: string; | ||
channelId?: string; | ||
} |
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
17 changes: 17 additions & 0 deletions
17
packages/application-generic/src/factories/sms/handlers/eazy-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,17 @@ | ||
import { ChannelTypeEnum, ICredentials } from '@novu/shared'; | ||
import { EazySmsProvider } from '@novu/eazy-sms'; | ||
import { BaseSmsHandler } from './base.handler'; | ||
|
||
export class EazySmsHandler extends BaseSmsHandler { | ||
constructor() { | ||
super('eazy-sms', ChannelTypeEnum.SMS); | ||
} | ||
|
||
buildProvider(credentials: ICredentials) { | ||
const config = { | ||
apiKey: credentials.apiKey, | ||
channelId: credentials.channelId, | ||
}; | ||
this.provider = new EazySmsProvider(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
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,14 @@ | ||
# Novu Eazy SMS Provider | ||
|
||
A EazySms sms provider library for [@novu/node](https://github.com/novuhq/novu) | ||
|
||
## Usage | ||
|
||
```javascript | ||
import { EazySmsProvider } from '@novu/eazy-sms'; | ||
|
||
const provider = new EazySmsProvider({ | ||
apiKey: process.env.API_KEY, | ||
channelId: process.env.CHANNEL_ID, | ||
}); | ||
``` |
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/eazy-sms", | ||
"version": "0.24.1", | ||
"description": "A eazy-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.24.1", | ||
"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/eazy-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,31 @@ | ||
import { EazySmsProvider } from './eazy-sms.provider'; | ||
|
||
const mockConfig = { | ||
apiKey: 'test-key', | ||
channelId: '[email protected]', | ||
}; | ||
|
||
const mockSMSMessage = { | ||
to: '1234567890', | ||
content: 'sms content', | ||
}; | ||
|
||
test('should trigger eazy-sms library correctly', async () => { | ||
const smsProvider = new EazySmsProvider(mockConfig); | ||
const spy = jest | ||
.spyOn(smsProvider, 'sendMessage') | ||
.mockImplementation(async () => { | ||
return { | ||
id: '2574a339-86ff', | ||
date: new Date().toISOString(), | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
} as any; | ||
}); | ||
|
||
await smsProvider.sendMessage(mockSMSMessage); | ||
expect(spy).toHaveBeenCalled(); | ||
expect(spy).toHaveBeenCalledWith({ | ||
content: 'sms content', | ||
to: '1234567890', | ||
}); | ||
}); | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test for the
EazySmsProvider
is well-structured and covers the basic functionality of thesendMessage
method. The use of Jest for spying and mocking the method ensures that the test is isolated and reliable. However, consider adding more test cases to cover error handling and edge cases to ensure robustness.Would you like me to help in writing additional test cases for error scenarios and edge cases?