-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5035 from varsubham/feat/rocket-chat
feat(provider): add rocket.chat chat provider
- Loading branch information
Showing
22 changed files
with
346 additions
and
10 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions
6
apps/web/public/static/images/providers/dark/square/rocket-chat.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions
6
apps/web/public/static/images/providers/light/rocket-chat.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions
6
apps/web/public/static/images/providers/light/square/rocket-chat.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
18 changes: 18 additions & 0 deletions
18
packages/application-generic/src/factories/chat/handlers/rocket-chat.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,18 @@ | ||
import { ICredentials, ChatProviderIdEnum } from '@novu/shared'; | ||
import { ChannelTypeEnum } from '@novu/stateless'; | ||
import { BaseChatHandler } from './base.handler'; | ||
import { RocketChatProvider } from '@novu/rocket-chat'; | ||
|
||
export class RocketChatHandler extends BaseChatHandler { | ||
constructor() { | ||
super(ChatProviderIdEnum.RocketChat, ChannelTypeEnum.CHAT); | ||
} | ||
|
||
buildProvider(credentials: ICredentials) { | ||
const config: { token: string; user: string } = { | ||
token: credentials.token as string, | ||
user: credentials.user as string, | ||
}; | ||
this.provider = new RocketChatProvider(config); | ||
} | ||
} |
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 RocketChat Provider | ||
|
||
A RocketChat chat provider library for [@novu/node](https://github.com/novuhq/novu) | ||
|
||
## Usage | ||
|
||
```javascript | ||
import { RocketChatProvider } from '@novu/rocket-chat'; | ||
|
||
const provider = new RocketChatProvider({ | ||
user: process.env.ROCKET_CHAT_USER_ID, | ||
token: process.env.ROCKET_CHAT_TOKEN, | ||
}); | ||
``` |
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/rocket-chat", | ||
"version": "0.22.0", | ||
"description": "A rocket-chat 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", | ||
"axios": "^1.6.2" | ||
}, | ||
"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/rocket-chat.provider'; |
29 changes: 29 additions & 0 deletions
29
providers/rocket-chat/src/lib/rocket-chat.provider.spec.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,29 @@ | ||
import { RocketChatProvider } from './rocket-chat.provider'; | ||
|
||
test('should trigger rocket-chat library correctly', async () => { | ||
const mockConfig = { | ||
user: '<your-user>', | ||
token: '<your-auth-token>', | ||
}; | ||
const provider = new RocketChatProvider(mockConfig); | ||
|
||
const spy = jest | ||
.spyOn(provider, 'sendMessage') | ||
.mockImplementation(async () => { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
return {} as any; | ||
}); | ||
|
||
await provider.sendMessage({ | ||
webhookUrl: '<your-root-url>', | ||
channel: '<your-channel>', | ||
content: '<your-chat-message>', | ||
}); | ||
|
||
expect(spy).toHaveBeenCalled(); | ||
expect(spy).toHaveBeenCalledWith({ | ||
webhookUrl: '<your-root-url>', | ||
channel: '<your-channel>', | ||
content: '<your-chat-message>', | ||
}); | ||
}); |
Oops, something went wrong.