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

Amqp provider based on #3812 #4040

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 2 additions & 0 deletions apps/web/public/static/images/providers/dark/amqp-sms.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions apps/web/public/static/images/providers/light/amqp-sms.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 20 additions & 11 deletions libs/shared/src/consts/providers/channels/sms.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
import { IProviderConfig } from '../provider.interface';
import {
gupshupConfig,
nexmoConfig,
plivoConfig,
sms77Config,
snsConfig,
telnyxConfig,
twilioConfig,
firetextConfig,
infobipSMSConfig,
africasTalkingConfig,
amqpSmsConfig,
burstSmsConfig,
clickatellConfig,
firetextConfig,
fortySixElksConfig,
gupshupConfig,
infobipSMSConfig,
kannelConfig,
maqsamConfig,
nexmoConfig,
plivoConfig,
sendchampConfig,
sms77Config,
smsCentralConfig,
snsConfig,
telnyxConfig,
termiiConfig,
africasTalkingConfig,
sendchampConfig,
twilioConfig,
} from '../credentials';
import { SmsProviderIdEnum } from '../provider.enum';

Expand Down Expand Up @@ -179,4 +180,12 @@ export const smsProviders: IProviderConfig[] = [
docReference: 'https://sendchamp.readme.io/reference/api-structure',
logoFileName: { light: 'sendchamp.svg', dark: 'sendchamp.svg' },
},
{
id: SmsProviderIdEnum.AmqpSms,
displayName: 'Amqp',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
displayName: 'Amqp',
displayName: 'AMQP',

For the display name let's keep the acronym in capitals as it is not code syntax.

channel: ChannelTypeEnum.SMS,
credentials: amqpSmsConfig,
docReference: '',
logoFileName: { light: 'amqp-sms.svg', dark: 'amqp-sms.svg' },
},
];
Original file line number Diff line number Diff line change
Expand Up @@ -740,3 +740,36 @@ export const sendchampConfig: IConfigCredentials[] = [
},
...smsConfigBase,
];

export const amqpSmsConfig: IConfigCredentials[] = [
{
key: CredentialsKeyEnum.ApiKey,
displayName: 'Amqp Queue',
type: 'text',
required: true,
},
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess from the perspective of AMQP the field from is not while it is mandatory for us in the SMS credentials configuration. But this raises the question if the channel SMS is the right one or if AMQP should live in a channel of its own, even if AMQP can be applied to manage SMS, because what would be the typical interface of an entity SMS (From number or ID, To number and message) seems not to apply to AMQP.

@scopsy I think this is an important point that we should discuss, if gathering providers by channel should be done by goal or by message entity type.

key: CredentialsKeyEnum.Host,
displayName: 'Amqp Host',
type: 'text',
required: true,
},
{
key: CredentialsKeyEnum.Port,
displayName: 'Amqp port',
type: 'text',
required: true,
},
{
key: CredentialsKeyEnum.User,
displayName: 'Amqp user',
type: 'text',
required: true,
},
{
key: CredentialsKeyEnum.Password,
displayName: 'Amqp password',
type: 'password',
required: true,
},
];
1 change: 1 addition & 0 deletions libs/shared/src/consts/providers/provider.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export enum SmsProviderIdEnum {
AfricasTalking = 'africas-talking',
Novu = 'novu-sms',
Sendchamp = 'sendchamp',
AmqpSms = 'amqp-sms',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
AmqpSms = 'amqp-sms',
Amqp = 'amqp',

We don't need to specify it is for the SMS channel. We add the channel to the enum key and value for the cases that a provider can send notifications to more than one channel.

}

export enum ChatProviderIdEnum {
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 @@ -91,6 +91,7 @@
"@novu/termii": "^0.18.0",
"@novu/testing": "^0.18.0",
"@novu/twilio": "^0.18.0",
"@novu/amqp-sms": "0.16.3",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The provider versions are outdated as unfortunately this PR has taken long for us to review. It will need updates.

"@sentry/node": "^7.12.1",
"analytics-node": "^6.2.0",
"bullmq": "^3.10.2",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { ChannelTypeEnum } from '@novu/shared';
import { BaseSmsHandler } from './base.handler';
import { AmqpSmsProvider } from '@novu/amqp-sms';

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

buildProvider(credentials: any) {
this.provider = new AmqpSmsProvider({
apiKey: credentials.apiKey,
host: credentials.host,
port: credentials.port,
user: credentials.user,
password: credentials.password,
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ export * from './sms-central.handler';
export * from './africas-talking.handler';
export * from './sendchamp.handler';
export * from './novu.handler';
export * from './amqp-sms.handler';
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 @@ -19,6 +19,7 @@ import {
AfricasTalkingSmsHandler,
SendchampSmsHandler,
NovuSmsHandler,
AmqpSmsHandler,
} from './handlers';

export class SmsFactory implements ISmsFactory {
Expand All @@ -41,6 +42,7 @@ export class SmsFactory implements ISmsFactory {
new AfricasTalkingSmsHandler(),
new SendchampSmsHandler(),
new NovuSmsHandler(),
new AmqpSmsHandler(),
];

getHandler(integration: IntegrationEntity) {
Expand Down
85 changes: 82 additions & 3 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/amqp-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/amqp-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/amqp-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
9 changes: 9 additions & 0 deletions providers/amqp-sms/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Novu AmqpSms Provider

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

## Usage

```javascript
FILL IN THE INITIALIZATION USAGE
```
Comment on lines +1 to +9
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Novu AmqpSms Provider
A AmqpSms sms provider library for [@novu/node](https://github.com/novuhq/novu)
## Usage
```javascript
FILL IN THE INITIALIZATION USAGE
```
# Novu AMQP Provider
A AMQP sms provider library for [@novu/node](https://github.com/novuhq/novu)
## Usage
```javascript
FILL IN THE INITIALIZATION USAGE

Please add the usage.

5 changes: 5 additions & 0 deletions providers/amqp-sms/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',
};
Loading