Skip to content

Commit 40eee0b

Browse files
fix(provider): fix import error for aws, pubnub and nodemailer (#52)
BREAKING CHANGE: change import path for specific providers GH-30
1 parent ad5889b commit 40eee0b

File tree

5 files changed

+89
-36
lines changed

5 files changed

+89
-36
lines changed

.vscode/settings.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
"**/.git": true,
1515
"**/.hg": true,
1616
"**/.svn": true,
17-
"**/CVS": true,
18-
"dist": true,
17+
"**/CVS": true
1918
},
2019
"files.insertFinalNewline": true,
2120
"files.trimTrailingWhitespace": true,

README.md

Lines changed: 46 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,19 @@ After the above, you need to configure one of the notification provider at least
5757

5858
### Email Notifications
5959

60-
This extension provides in-built support of AWS Simple Email Service integration for sending emails from the application. In order to use it, just bind the SesProvider as below in application.ts.
60+
This extension provides in-built support of AWS Simple Email Service integration for sending emails from the application. In order to use it, run `npm install aws-sdk`, and then bind the SesProvider as below in application.ts.
6161

6262
```ts
6363
import {
6464
NotificationsComponent,
6565
NotificationBindings,
66-
SesProvider
6766
} from 'loopback4-notifications';
67+
import {
68+
SesProvider
69+
} from 'loopback-notifications/ses';
6870
....
6971

72+
7073
export class NotificationServiceApplication extends BootMixin(
7174
ServiceMixin(RepositoryMixin(RestApplication)),
7275
) {
@@ -86,9 +89,11 @@ There are some additional configurations needed in order to allow SES to connect
8689
import {
8790
NotificationsComponent,
8891
NotificationBindings,
89-
SESBindings,
90-
SesProvider
9192
} from 'loopback4-notifications';
93+
import {
94+
SesProvider,
95+
SESBindings,
96+
} from 'loopback-notifications/ses';
9297
....
9398

9499
export class NotificationServiceApplication extends BootMixin(
@@ -117,9 +122,11 @@ In addition to this, some general configurations can also be done, like below.
117122
import {
118123
NotificationsComponent,
119124
NotificationBindings,
120-
SESBindings,
121-
SesProvider
122125
} from 'loopback4-notifications';
126+
import {
127+
SesProvider,
128+
SESBindings,
129+
} from 'loopback-notifications/ses';
123130
....
124131

125132
export class NotificationServiceApplication extends BootMixin(
@@ -159,14 +166,16 @@ this.bind(NotificationBindings.EmailProvider).toProvider(MyOwnProvider);
159166

160167
### Email Notifications Using Nodemailer
161168

162-
This extension provides in-built support of Nodemailer integration for sending emails from the application. In order to use it, just bind the NodemailerProvider as below in application.ts.
169+
This extension provides in-built support of Nodemailer integration for sending emails from the application. In order to use it, run `npm install nodemailer`, and then bind the NodemailerProvider as below in application.ts.
163170

164171
```ts
165172
import {
166173
NotificationsComponent,
167174
NotificationBindings,
168-
NodemailerProvider
169175
} from 'loopback4-notifications';
176+
import {
177+
NodemailerProvider
178+
} from 'loopback4-notifications/nodemailer';
170179
....
171180

172181
export class NotificationServiceApplication extends BootMixin(
@@ -188,9 +197,11 @@ There are some additional configurations needed in order to allow NodeMailer to
188197
import {
189198
NotificationsComponent,
190199
NotificationBindings,
191-
NodemailerBindings,
192-
NodemailerProvider
193200
} from 'loopback4-notifications';
201+
import {
202+
NodemailerProvider,
203+
NodemailerBindings,
204+
} from 'loopback4-notifications/nodemailer';
194205
....
195206

196207
export class NotificationServiceApplication extends BootMixin(
@@ -229,9 +240,11 @@ In addition to this, some general configurations can also be done, like below.
229240
import {
230241
NotificationsComponent,
231242
NotificationBindings,
232-
NodemailerBindings,
233-
NodemailerProvider
234243
} from 'loopback4-notifications';
244+
import {
245+
NodemailerProvider,
246+
NodemailerBindings,
247+
} from 'loopback4-notifications/nodemailer';
235248
....
236249

237250
export class NotificationServiceApplication extends BootMixin(
@@ -281,14 +294,16 @@ this.bind(NotificationBindings.EmailProvider).toProvider(MyOwnProvider);
281294

282295
### SMS Notifications
283296

284-
This extension provides in-built support of AWS Simple Notification Service integration for sending SMS from the application. In order to use it, just bind the SnsProvider as below in application.ts.
297+
This extension provides in-built support of AWS Simple Notification Service integration for sending SMS from the application. In order to use it, run `npm install aws-sdk`, and then bind the SnsProvider as below in application.ts.
285298

286299
```ts
287300
import {
288301
NotificationsComponent,
289302
NotificationBindings,
290-
SnsProvider
291303
} from 'loopback4-notifications';
304+
import {
305+
SnsProvider
306+
} from 'loopback4-notification/sns';
292307
....
293308

294309
export class NotificationServiceApplication extends BootMixin(
@@ -310,9 +325,11 @@ There are some additional configurations needed in order to allow SNS to connect
310325
import {
311326
NotificationsComponent,
312327
NotificationBindings,
328+
} from 'loopback4-notifications';
329+
import {
313330
SNSBindings,
314331
SnsProvider
315-
} from 'loopback4-notifications';
332+
} from 'loopback4-notification/sns';
316333
....
317334

318335
export class NotificationServiceApplication extends BootMixin(
@@ -343,14 +360,16 @@ this.bind(NotificationBindings.SMSProvider).toProvider(MyOwnProvider);
343360

344361
### Push Notifications with Pubnub
345362

346-
This extension provides in-built support of Pubnub integration for sending realtime push notifications from the application. In order to use it, just bind the PushProvider as below in application.ts.
363+
This extension provides in-built support of Pubnub integration for sending realtime push notifications from the application. In order to use it, run `npm install pubnub`, and then bind the PushProvider as below in application.ts.
347364

348365
```ts
349366
import {
350367
NotificationsComponent,
351368
NotificationBindings,
352-
PubNubProvider
353369
} from 'loopback4-notifications';
370+
import {
371+
PubNubProvider
372+
} from 'loopback4-notifications/pubnub';
354373
....
355374

356375
export class NotificationServiceApplication extends BootMixin(
@@ -372,9 +391,11 @@ There are some additional configurations needed in order to allow Pubnub connect
372391
import {
373392
NotificationsComponent,
374393
NotificationBindings,
394+
} from 'loopback4-notifications';
395+
import {
375396
PubnubBindings,
376397
PubNubProvider
377-
} from 'loopback4-notifications';
398+
} from 'loopback4-notifications/pubnub';
378399
....
379400

380401
export class NotificationServiceApplication extends BootMixin(
@@ -415,7 +436,7 @@ this.bind(NotificationBindings.SMSProvider).toProvider(MyOwnProvider);
415436

416437
### Push Notifications With Socket.io
417438

418-
This extension provides in-built support of Socket.io integration for sending realtime notifications from the application. In order to use it, just bind the PushProvider as below in application.ts.
439+
This extension provides in-built support of Socket.io integration for sending realtime notifications from the application. In order to use it, run `npm install socket.io-client`, and bind the PushProvider as below in application.ts.
419440

420441
This provider sends the message to the channel passed via config (or while publishing) and accepts a fix interface to interact with.
421442
The interface could be imported into the project by the name SocketMessage.
@@ -424,8 +445,10 @@ The interface could be imported into the project by the name SocketMessage.
424445
import {
425446
NotificationsComponent,
426447
NotificationBindings,
427-
SocketIOProvider
428448
} from 'loopback4-notifications';
449+
import {
450+
SocketIOProvider
451+
} from 'loopback4-notifications/socketio';
429452
....
430453

431454
export class NotificationServiceApplication extends BootMixin(
@@ -447,9 +470,11 @@ There are some additional configurations needed in order to allow Socket connect
447470
import {
448471
NotificationsComponent,
449472
NotificationBindings,
473+
} from 'loopback4-notifications';
474+
import {
450475
SocketBindings,
451476
SocketIOProvider
452-
} from 'loopback4-notifications';
477+
} from 'loopback4-notifications/socketio';
453478
....
454479

455480
export class NotificationServiceApplication extends BootMixin(

package.json

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,43 @@
88
],
99
"main": "dist/index.js",
1010
"types": "dist/index.d.ts",
11+
"exports": {
12+
".": "./dist/index.js",
13+
"./nodemailer": {
14+
"type": "./dist/providers/email/nodemailer/index.d.ts",
15+
"default": "./dist/providers/email/nodemailer/index.js"
16+
},
17+
"./ses": {
18+
"type": "./dist/providers/email/ses/index.d.ts",
19+
"default": "./dist/providers/email/ses/index.js"
20+
},
21+
"./fcm": {
22+
"type": "./dist/providers/push/fcm/index.d.ts",
23+
"default": "./dist/providers/push/fcm/index.js"
24+
},
25+
"./pubnub": {
26+
"type": "./dist/providers/push/pubnub/index.d.ts",
27+
"default": "./dist/providers/push/pubnub/index.js"
28+
},
29+
"./socketio": {
30+
"type": "./dist/providers/push/socketio/index.d.ts",
31+
"default": "./dist/providers/push/socketio/index.js"
32+
},
33+
"./sns": {
34+
"type": "./dist/providers/sms/sns/index.d.ts",
35+
"default": "./dist/providers/sms/sns/index.js"
36+
}
37+
},
38+
"typesVersions": {
39+
"*": {
40+
"nodemailer": ["./dist/providers/email/nodemailer/index.d.ts"],
41+
"ses": ["./dist/providers/email/ses/index.d.ts"],
42+
"fcm": ["./dist/providers/push/fcm/index.d.ts"],
43+
"pubnub": ["./dist/providers/push/pubnub/index.d.ts"],
44+
"socketio": ["./dist/providers/push/socketio/index.d.ts"],
45+
"sns": ["./dist/providers/sms/sns/index.d.ts"]
46+
}
47+
},
1148
"engines": {
1249
"node": ">=10"
1350
},
@@ -83,13 +120,6 @@
83120
"source-map-support": "^0.5.21",
84121
"typescript": "~4.7.3"
85122
},
86-
"peerDependencies": {
87-
"aws-sdk": "^2.1142.0",
88-
"firebase-admin": "^10.3.0",
89-
"nodemailer": "^6.7.5",
90-
"pubnub": "^7.0.1",
91-
"socket.io-client": "^4.5.1"
92-
},
93123
"overrides": {
94124
"commitizen": {
95125
"minimist": "^1.2.6",

src/component.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import {Binding, Component, ProviderMap} from '@loopback/core';
22
import {NotificationBindings} from './keys';
3-
import {NotificationProvider} from './providers';
4-
import {SESBindings} from './providers/email';
5-
import {PubnubBindings} from './providers/push';
6-
import {SocketBindings} from './providers/push/socketio';
7-
import {SNSBindings} from './providers/sms/sns';
3+
import {SESBindings} from './providers/email/ses/keys';
4+
import {NotificationProvider} from './providers/notification.provider';
5+
import {PubnubBindings} from './providers/push/pubnub/keys';
6+
import {SocketBindings} from './providers/push/socketio/keys';
7+
import {SNSBindings} from './providers/sms/sns/keys';
88

99
export class NotificationsComponent implements Component {
1010
constructor() {}

src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
export * from './component';
22
export * from './error-keys';
33
export * from './keys';
4-
export * from './providers';
54
export * from './types';

0 commit comments

Comments
 (0)