@nathapp/nestjs-notification 1.0.0-rc.5 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/email/constant.js +1 -0
- package/dist/email/constant.js.map +1 -0
- package/dist/email/email-provider.factory.js +1 -0
- package/dist/email/email-provider.factory.js.map +1 -0
- package/dist/email/email.interface.js +1 -0
- package/dist/email/email.interface.js.map +1 -0
- package/dist/email/email.module.d.ts +3 -0
- package/dist/email/email.module.js +20 -5
- package/dist/email/email.module.js.map +1 -0
- package/dist/email/email.provider.d.ts +2 -0
- package/dist/email/email.provider.js +12 -0
- package/dist/email/email.provider.js.map +1 -0
- package/dist/email/email.service.d.ts +1 -1
- package/dist/email/email.service.js +3 -2
- package/dist/email/email.service.js.map +1 -0
- package/dist/email/index.d.ts +2 -2
- package/dist/email/index.js +3 -1
- package/dist/email/index.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/interface/index.d.ts +4 -2
- package/dist/interface/index.js +1 -0
- package/dist/interface/index.js.map +1 -0
- package/dist/interface/message.interface.d.ts +13 -0
- package/dist/interface/message.interface.js +1 -0
- package/dist/interface/message.interface.js.map +1 -0
- package/dist/interface/payload.inteface.d.ts +22 -0
- package/dist/interface/payload.inteface.js +3 -0
- package/dist/interface/payload.inteface.js.map +1 -0
- package/dist/interface/result.interface.d.ts +5 -0
- package/dist/interface/result.interface.js +1 -0
- package/dist/interface/result.interface.js.map +1 -0
- package/dist/notification/constant.js +1 -0
- package/dist/notification/constant.js.map +1 -0
- package/dist/notification/index.d.ts +2 -2
- package/dist/notification/index.js +1 -0
- package/dist/notification/index.js.map +1 -0
- package/dist/notification/notification.module.d.ts +28 -5
- package/dist/notification/notification.module.js +149 -10
- package/dist/notification/notification.module.js.map +1 -0
- package/dist/notification/notification.service.d.ts +14 -3
- package/dist/notification/notification.service.js +135 -10
- package/dist/notification/notification.service.js.map +1 -0
- package/dist/push-notification/constant.d.ts +1 -0
- package/dist/push-notification/constant.js +5 -0
- package/dist/push-notification/constant.js.map +1 -0
- package/dist/push-notification/fcm-push-notification.provider.d.ts +13 -0
- package/dist/push-notification/fcm-push-notification.provider.js +78 -0
- package/dist/push-notification/fcm-push-notification.provider.js.map +1 -0
- package/dist/push-notification/firebase.interface.d.ts +144 -0
- package/dist/push-notification/firebase.interface.js +3 -0
- package/dist/push-notification/firebase.interface.js.map +1 -0
- package/dist/push-notification/index.d.ts +11 -0
- package/dist/push-notification/index.js +24 -0
- package/dist/push-notification/index.js.map +1 -0
- package/dist/push-notification/push-notification-module.interface.d.ts +33 -0
- package/dist/push-notification/push-notification-module.interface.js +4 -0
- package/dist/push-notification/push-notification-module.interface.js.map +1 -0
- package/dist/push-notification/push-notification-provider-module.factory.d.ts +5 -0
- package/dist/push-notification/push-notification-provider-module.factory.js +13 -0
- package/dist/push-notification/push-notification-provider-module.factory.js.map +1 -0
- package/dist/push-notification/push-notification-provider.factory.d.ts +5 -0
- package/dist/push-notification/push-notification-provider.factory.js +16 -0
- package/dist/push-notification/push-notification-provider.factory.js.map +1 -0
- package/dist/push-notification/push-notification-provider.manager.d.ts +13 -0
- package/dist/push-notification/push-notification-provider.manager.js +38 -0
- package/dist/push-notification/push-notification-provider.manager.js.map +1 -0
- package/dist/push-notification/push-notification.interface.d.ts +16 -0
- package/dist/push-notification/push-notification.interface.js +11 -0
- package/dist/push-notification/push-notification.interface.js.map +1 -0
- package/dist/push-notification/push-notification.module.d.ts +15 -0
- package/dist/push-notification/push-notification.module.js +189 -0
- package/dist/push-notification/push-notification.module.js.map +1 -0
- package/dist/push-notification/push-notification.provider.d.ts +12 -0
- package/dist/push-notification/push-notification.provider.js +7 -0
- package/dist/push-notification/push-notification.provider.js.map +1 -0
- package/dist/push-notification/push-notification.service.d.ts +15 -0
- package/dist/push-notification/push-notification.service.js +66 -0
- package/dist/push-notification/push-notification.service.js.map +1 -0
- package/dist/push-notification/user-token.store.d.ts +19 -0
- package/dist/push-notification/user-token.store.js +44 -0
- package/dist/push-notification/user-token.store.js.map +1 -0
- package/dist/sms/index.js +1 -0
- package/dist/sms/index.js.map +1 -0
- package/dist/sms/sms.service.js +1 -0
- package/dist/sms/sms.service.js.map +1 -0
- package/dist/template/constant.js +1 -0
- package/dist/template/constant.js.map +1 -0
- package/dist/template/fake-template.loader.d.ts +3 -0
- package/dist/template/fake-template.loader.js +15 -1
- package/dist/template/fake-template.loader.js.map +1 -0
- package/dist/template/index.d.ts +2 -2
- package/dist/template/index.js +3 -1
- package/dist/template/index.js.map +1 -0
- package/dist/template/template.loader.js +3 -2
- package/dist/template/template.loader.js.map +1 -0
- package/dist/template/template.service.js +3 -2
- package/dist/template/template.service.js.map +1 -0
- package/package.json +15 -21
- package/.eslintrc.js +0 -24
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notification.module.js","sourceRoot":"","sources":["../../lib/notification/notification.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAQwB;AACxB,oCAAoF;AACpF,yCAAkD;AAClD,0CAAkF;AAClF,mEAA+D;AAC/D,iEAA6D;AAC7D,4DAAiI;AAEjI,MAAM,cAAc,GAAwE;IAC1F,eAAe,EAAE,kCAAe;IAChC,cAAc,EAAE,6BAAkB;IAClC,mBAAmB,EAAE,0CAAmB;CACzC,CAAC;AAMK,IAAM,kBAAkB,0BAAxB,MAAM,kBAAkB;IAC7B,MAAM,CAAC,OAAO,CAAC,OAAkC;QAC/C,OAAO,GAAG,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;QAEzC,MAAM,OAAO,GAAG,EAAE,CAAC;QACnB,MAAM,EAAE,YAAY,EAAE,uBAAuB,EAAE,GAAG,OAAO,CAAC;QAE1D,IAAI,YAAY,EAAE,CAAC;YACjB,IAAI,IAAI,CAAC,wBAAwB,CAAC,YAAY,CAAC,EAAE,CAAC;gBAChD,OAAO,CAAC,IAAI,CAAC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AAgB,CAAC,CAAC,MAAM,cAAc,CAAC,aAAa,EAAE,CAAQ,CAAC;YACtE,MAAM,EAAE,CAAC,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,WAAW,CAAC;SAClD,CAAC;IACJ,CAAC;CACF,CAAA;AA9OY,gDAAkB;6BAAlB,kBAAkB;IAD9B,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,kBAAkB,CA8O9B;AAoCD,MAAM,sBAAsB,GAAG,CAAC,OAAY,EAAmC,EAAE;IAC/E,OAAO,aAAa,IAAI,OAAO,IAAI,UAAU,IAAI,OAAO,IAAI,YAAY,IAAI,OAAO,CAAC;AACtF,CAAC,CAAA"}
|
|
@@ -1,10 +1,21 @@
|
|
|
1
1
|
import { ResolveOption, TemplateLoader } from "../template";
|
|
2
2
|
import { EmailService } from "../email";
|
|
3
|
-
import { SendResult } from "../interface
|
|
3
|
+
import { BatchSendResult, SendResult, EmailAttachment, EmailMessage, PushMessage, PushMessageOnly, EmailNotificationPayload, PushNotificationPayload } from "../interface";
|
|
4
|
+
import { DeviceToken, PushNotificationService } from "../push-notification";
|
|
4
5
|
export declare class NotificationService {
|
|
5
6
|
private readonly templateLoader;
|
|
6
7
|
private readonly emailService;
|
|
8
|
+
private readonly pushNotificationService;
|
|
7
9
|
private readonly logger;
|
|
8
|
-
constructor(templateLoader: TemplateLoader, emailService: EmailService);
|
|
9
|
-
|
|
10
|
+
constructor(templateLoader: TemplateLoader, emailService: EmailService, pushNotificationService: PushNotificationService);
|
|
11
|
+
sendEmailRaw(message: EmailMessage): Promise<SendResult>;
|
|
12
|
+
sendEmail(payload: EmailNotificationPayload): Promise<SendResult>;
|
|
13
|
+
sendEmail(templateCode: string, email: string, resolveOption: ResolveOption, attachments: EmailAttachment[]): Promise<SendResult>;
|
|
14
|
+
sendPushNotificationRaw(message: PushMessage): Promise<SendResult>;
|
|
15
|
+
sendPushNotification(payload: PushNotificationPayload): Promise<SendResult>;
|
|
16
|
+
sendPushNotification(templateCode: string, token: string | number | DeviceToken, resolveOption: ResolveOption): Promise<SendResult>;
|
|
17
|
+
sendPushNotificationMulticastRaw(tokens: DeviceToken[], message: PushMessageOnly): Promise<BatchSendResult>;
|
|
18
|
+
sendPushNotificationMulticast(templateCode: string, tokens: DeviceToken[], resolveOption: ResolveOption): Promise<BatchSendResult>;
|
|
19
|
+
protected isEmailPayload(value: any): value is EmailNotificationPayload;
|
|
20
|
+
protected isPushNotificationPayload(value: any): value is PushNotificationPayload;
|
|
10
21
|
}
|
|
@@ -11,39 +11,164 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
12
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
13
|
};
|
|
14
|
+
var NotificationService_1;
|
|
14
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
16
|
exports.NotificationService = void 0;
|
|
16
17
|
const common_1 = require("@nestjs/common");
|
|
17
18
|
const template_1 = require("../template");
|
|
18
19
|
const email_1 = require("../email");
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
const push_notification_1 = require("../push-notification");
|
|
21
|
+
let NotificationService = NotificationService_1 = class NotificationService {
|
|
22
|
+
constructor(templateLoader, emailService, pushNotificationService) {
|
|
21
23
|
this.templateLoader = templateLoader;
|
|
22
24
|
this.emailService = emailService;
|
|
23
|
-
this.
|
|
25
|
+
this.pushNotificationService = pushNotificationService;
|
|
26
|
+
this.logger = new common_1.Logger(NotificationService_1.name);
|
|
27
|
+
const services = [];
|
|
28
|
+
services.push(templateLoader.constructor.name);
|
|
29
|
+
if (emailService)
|
|
30
|
+
services.push(emailService.constructor.name);
|
|
31
|
+
if (pushNotificationService)
|
|
32
|
+
services.push(pushNotificationService.constructor.name);
|
|
33
|
+
this.logger.log(`NotificationService initialized with ${services.join(', ')} services`);
|
|
24
34
|
}
|
|
25
|
-
async
|
|
35
|
+
async sendEmailRaw(message) {
|
|
26
36
|
if (!this.emailService) {
|
|
27
|
-
this.logger.error("Email Service is
|
|
37
|
+
this.logger.error("Email Service is not configure..please configure the email option");
|
|
38
|
+
return {
|
|
39
|
+
success: false,
|
|
40
|
+
message: "Email Service is not configure"
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
return this.emailService.send(message);
|
|
44
|
+
}
|
|
45
|
+
async sendEmail(templateCodeOrPayload, email, resolveOption, attachments) {
|
|
46
|
+
let resolvedTemplateCode = '';
|
|
47
|
+
let resolvedEmail = '';
|
|
48
|
+
let resolvedResolveOption = {};
|
|
49
|
+
let resolvedAttachments = [];
|
|
50
|
+
if (this.isEmailPayload(templateCodeOrPayload)) {
|
|
51
|
+
resolvedTemplateCode = templateCodeOrPayload.templateCode;
|
|
52
|
+
resolvedEmail = templateCodeOrPayload.email;
|
|
53
|
+
resolvedResolveOption = templateCodeOrPayload.options || {};
|
|
54
|
+
resolvedAttachments = templateCodeOrPayload.attachments;
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
resolvedTemplateCode = templateCodeOrPayload || '';
|
|
58
|
+
resolvedEmail = email || '';
|
|
59
|
+
resolvedResolveOption = resolveOption || {};
|
|
60
|
+
resolvedAttachments = attachments || [];
|
|
61
|
+
}
|
|
62
|
+
const templateMessage = await this.templateLoader.resolve(resolvedTemplateCode, resolvedResolveOption);
|
|
63
|
+
if (!templateMessage) {
|
|
64
|
+
this.logger.error(`Template ${resolvedTemplateCode} resolve failure. Please make sure the template has set`);
|
|
65
|
+
return {
|
|
66
|
+
success: false,
|
|
67
|
+
message: `Template ${resolvedTemplateCode} resolve failure. Please make sure the template has set`
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
return this.sendEmailRaw({
|
|
71
|
+
recipient: resolvedEmail,
|
|
72
|
+
subject: templateMessage.subject || "",
|
|
73
|
+
message: templateMessage.content,
|
|
74
|
+
attachments: resolvedAttachments,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
async sendPushNotificationRaw(message) {
|
|
78
|
+
if (!this.pushNotificationService) {
|
|
79
|
+
this.logger.error("Push Notification Service is not configure..please configure the pushNotification option");
|
|
80
|
+
return {
|
|
81
|
+
success: false,
|
|
82
|
+
message: "Push Notification Service is not configure..please configure the pushNotification option"
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
return this.pushNotificationService.send(message);
|
|
86
|
+
}
|
|
87
|
+
async sendPushNotification(templateCodeOrPayload, token, resolveOption) {
|
|
88
|
+
let resolvedTemplateCode = '';
|
|
89
|
+
let resolvedToken;
|
|
90
|
+
let resolvedDeviceToken;
|
|
91
|
+
let resolvedResolveOption = {};
|
|
92
|
+
if (this.isPushNotificationPayload(templateCodeOrPayload)) {
|
|
93
|
+
resolvedTemplateCode = templateCodeOrPayload.templateCode;
|
|
94
|
+
resolvedResolveOption = templateCodeOrPayload.options || {};
|
|
95
|
+
resolvedToken = templateCodeOrPayload.userId || templateCodeOrPayload.deviceToken;
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
resolvedTemplateCode = templateCodeOrPayload || '';
|
|
99
|
+
resolvedResolveOption = resolveOption || {};
|
|
100
|
+
resolvedToken = token;
|
|
101
|
+
}
|
|
102
|
+
if (!resolvedToken) {
|
|
103
|
+
this.logger.error(`Token is required to send push notification`);
|
|
104
|
+
return {
|
|
105
|
+
success: false,
|
|
106
|
+
message: `Token is required to send push notification`
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
if (typeof resolvedToken === 'string' || typeof resolvedToken === 'number') {
|
|
110
|
+
resolvedDeviceToken = await this.pushNotificationService.getUserDeviceToken(resolvedToken);
|
|
111
|
+
if (!resolvedDeviceToken) {
|
|
112
|
+
this.logger.error(`Device Token not found for user ${resolvedToken}`);
|
|
113
|
+
return {
|
|
114
|
+
success: false,
|
|
115
|
+
message: `Device Token not found for user ${resolvedToken}`
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
resolvedDeviceToken = resolvedToken;
|
|
121
|
+
}
|
|
122
|
+
const templateMessage = await this.templateLoader.resolve(resolvedTemplateCode, resolveOption);
|
|
123
|
+
if (!templateMessage) {
|
|
124
|
+
this.logger.error(`Template ${resolvedTemplateCode} resolve failure. Please make sure the template has set`);
|
|
125
|
+
return {
|
|
126
|
+
success: false,
|
|
127
|
+
message: `Template ${resolvedTemplateCode} resolve failure. Please make sure the template has set`
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
return this.sendPushNotificationRaw({
|
|
131
|
+
recipient: resolvedDeviceToken.data,
|
|
132
|
+
paltform: resolvedDeviceToken.type,
|
|
133
|
+
subject: templateMessage.subject || "",
|
|
134
|
+
message: templateMessage.content,
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
async sendPushNotificationMulticastRaw(tokens, message) {
|
|
138
|
+
if (!this.pushNotificationService) {
|
|
139
|
+
this.logger.error("PushNotification Service is not configure..please configure the pushNotification option");
|
|
28
140
|
return null;
|
|
29
141
|
}
|
|
142
|
+
return this.pushNotificationService.sendMulticast(tokens, message);
|
|
143
|
+
}
|
|
144
|
+
async sendPushNotificationMulticast(templateCode, tokens, resolveOption) {
|
|
30
145
|
const templateMessage = await this.templateLoader.resolve(templateCode, resolveOption);
|
|
31
146
|
if (!templateMessage) {
|
|
32
147
|
this.logger.error(`Template ${templateCode} Load Failed. Please make sure the template has set`);
|
|
33
148
|
return null;
|
|
34
149
|
}
|
|
35
|
-
return this.
|
|
36
|
-
recipient: email,
|
|
150
|
+
return this.sendPushNotificationMulticastRaw(tokens, {
|
|
37
151
|
subject: templateMessage.subject || "",
|
|
38
152
|
message: templateMessage.content,
|
|
39
153
|
});
|
|
40
154
|
}
|
|
155
|
+
isEmailPayload(value) {
|
|
156
|
+
return typeof value === 'object' && 'templateCode' in value && 'email' in value;
|
|
157
|
+
}
|
|
158
|
+
;
|
|
159
|
+
isPushNotificationPayload(value) {
|
|
160
|
+
return typeof value === 'object' && 'templateCode' in value && ('userId' in value || 'deviceToken' in value);
|
|
161
|
+
}
|
|
41
162
|
};
|
|
42
|
-
NotificationService =
|
|
163
|
+
exports.NotificationService = NotificationService;
|
|
164
|
+
exports.NotificationService = NotificationService = NotificationService_1 = __decorate([
|
|
43
165
|
__param(0, (0, common_1.Inject)(template_1.TEMPLATE_LOADER)),
|
|
44
166
|
__param(1, (0, common_1.Optional)()),
|
|
45
167
|
__param(1, (0, common_1.Inject)(email_1.EmailService)),
|
|
168
|
+
__param(2, (0, common_1.Optional)()),
|
|
169
|
+
__param(2, (0, common_1.Inject)(push_notification_1.PushNotificationService)),
|
|
46
170
|
__metadata("design:paramtypes", [template_1.TemplateLoader,
|
|
47
|
-
email_1.EmailService
|
|
171
|
+
email_1.EmailService,
|
|
172
|
+
push_notification_1.PushNotificationService])
|
|
48
173
|
], NotificationService);
|
|
49
|
-
|
|
174
|
+
//# sourceMappingURL=notification.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notification.service.js","sourceRoot":"","sources":["../../lib/notification/notification.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAA0D;AAC1D,0CAA6E;AAC7E,oCAAwC;AAExC,4DAA4E;AAE5E,IAAa,mBAAmB,2BAAhC,MAAa,mBAAmB;IAG9B,YAAqC,cAA+C,EAChD,YAA2C,EAChC,uBAAiE;QAF1D,mBAAc,GAAd,cAAc,CAAgB;QAC/B,iBAAY,GAAZ,YAAY,CAAc;QACf,4BAAuB,GAAvB,uBAAuB,CAAyB;QAH/F,WAAM,GAAG,IAAI,eAAM,CAAC,qBAAmB,CAAC,IAAI,CAAC,CAAC;QAK3D,MAAM,QAAQ,GAAG,EAAE,CAAC;QACpB,QAAQ,CAAC,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QAC/C,IAAG,YAAY;YAAE,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QAC9D,IAAG,uBAAuB;YAAE,Q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;8BAAnB,mBAAmB;IAGjB,WAAA,IAAA,eAAM,EAAC,0BAAe,CAAC,CAAA;IACjC,WAAA,IAAA,iBAAQ,GAAE,CAAA;IAAE,WAAA,IAAA,eAAM,EAAC,oBAAY,CAAC,CAAA;IAChC,WAAA,IAAA,iBAAQ,GAAE,CAAA;IAAE,WAAA,IAAA,eAAM,EAAC,2CAAuB,CAAC,CAAA;qCAFwB,yBAAc;QACjB,oBAAY;QACU,2CAAuB;GALrG,mBAAmB,CAgK/B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const PUSH_NOTIFICATION_PROVIDERS = "PUSH_NOTIFICATION_PROVIDERS";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constant.js","sourceRoot":"","sources":["../../lib/push-notification/constant.ts"],"names":[],"mappings":";;;AAAa,QAAA,2BAA2B,GAAG,6BAA6B,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FCMPushNotificationOption, PushNotificationPlatform } from "./push-notification.interface";
|
|
2
|
+
import { PushNotificationProvider } from "./push-notification.provider";
|
|
3
|
+
import { PushMessage, SendResult, PushMessageOnly, BatchSendResult } from "../interface";
|
|
4
|
+
export declare class FCMPushNotificationProvider extends PushNotificationProvider {
|
|
5
|
+
private readonly option;
|
|
6
|
+
private readonly client;
|
|
7
|
+
constructor(option: FCMPushNotificationOption);
|
|
8
|
+
get type(): PushNotificationPlatform;
|
|
9
|
+
send(message: PushMessage): Promise<SendResult>;
|
|
10
|
+
sendMulticast(tokens: string[], message: PushMessageOnly): Promise<BatchSendResult>;
|
|
11
|
+
private generateMessage;
|
|
12
|
+
private getFirebaseMessage;
|
|
13
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FCMPushNotificationProvider = void 0;
|
|
4
|
+
const load_package_util_1 = require("@nestjs/common/utils/load-package.util");
|
|
5
|
+
const push_notification_provider_1 = require("./push-notification.provider");
|
|
6
|
+
const common_1 = require("@nathapp/common");
|
|
7
|
+
class FCMPushNotificationProvider extends push_notification_provider_1.PushNotificationProvider {
|
|
8
|
+
constructor(option) {
|
|
9
|
+
super();
|
|
10
|
+
const Firebase = (0, load_package_util_1.loadPackage)('firebase-admin', FCMPushNotificationProvider.name, () => require('firebase-admin'));
|
|
11
|
+
this.option = option;
|
|
12
|
+
this.client = Firebase.initializeApp({
|
|
13
|
+
credential: Firebase.credential.cert(JSON.parse(option.serviceAccount)),
|
|
14
|
+
databaseURL: option.databaseUrl,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
get type() {
|
|
18
|
+
return "firebase";
|
|
19
|
+
}
|
|
20
|
+
async send(message) {
|
|
21
|
+
const firebaseMessage = this.generateMessage(message);
|
|
22
|
+
const messageId = await this.client.messaging().send(firebaseMessage);
|
|
23
|
+
return {
|
|
24
|
+
success: !(0, common_1.isUndefinedOrNullOrEmpty)(messageId),
|
|
25
|
+
requestId: messageId,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
async sendMulticast(tokens, message) {
|
|
29
|
+
const multicastMessage = this.getFirebaseMessage(tokens, message);
|
|
30
|
+
const batchResponse = await this.client.messaging().sendEachForMulticast(multicastMessage);
|
|
31
|
+
return {
|
|
32
|
+
results: batchResponse.responses.map(response => {
|
|
33
|
+
var _a;
|
|
34
|
+
return {
|
|
35
|
+
success: response.success,
|
|
36
|
+
requestId: response.messageId,
|
|
37
|
+
message: (_a = response.error) === null || _a === void 0 ? void 0 : _a.message,
|
|
38
|
+
extra: response.error
|
|
39
|
+
};
|
|
40
|
+
}),
|
|
41
|
+
successCount: batchResponse.successCount,
|
|
42
|
+
failureCount: batchResponse.failureCount,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
generateMessage(pushMessage) {
|
|
46
|
+
return this.getFirebaseMessage(pushMessage.recipient, pushMessage);
|
|
47
|
+
}
|
|
48
|
+
getFirebaseMessage(token, pushMessage) {
|
|
49
|
+
const partialMessage = {
|
|
50
|
+
notification: {
|
|
51
|
+
title: pushMessage.subject,
|
|
52
|
+
body: pushMessage.message,
|
|
53
|
+
},
|
|
54
|
+
data: pushMessage.data,
|
|
55
|
+
apns: {
|
|
56
|
+
payload: {
|
|
57
|
+
aps: {
|
|
58
|
+
mutableContent: true,
|
|
59
|
+
contentAvailable: true,
|
|
60
|
+
apnsPushType: "background"
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
if (Array.isArray(token)) {
|
|
66
|
+
return {
|
|
67
|
+
...partialMessage,
|
|
68
|
+
tokens: token
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
...partialMessage,
|
|
73
|
+
token: token
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
exports.FCMPushNotificationProvider = FCMPushNotificationProvider;
|
|
78
|
+
//# sourceMappingURL=fcm-push-notification.provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fcm-push-notification.provider.js","sourceRoot":"","sources":["../../lib/push-notification/fcm-push-notification.provider.ts"],"names":[],"mappings":";;;AAEA,8EAAqE;AACrE,6EAAwE;AAExE,4CAA2D;AAK3D,MAAa,2BAA4B,SAAQ,qDAAwB;IAGvE,YAAY,MAAiC;QAC3C,KAAK,EAAE,CAAC;QACR,MAAM,QAAQ,GAAG,IAAA,+BAAW,EAAC,gBAAgB,EAAE,2BAA2B,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC;QAClH,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC;YACnC,UAAU,EAAE,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,cAAc,CA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AAwB,EAAE,WAA0C;QAE7F,MAAM,cAAc,GAAyB;YAC3C,YAAY,EAAE;gBACV,KAAK,EAAE,WAAW,CAAC,OAAO;gBAC1B,IAAI,EAAE,WAAW,CAAC,OAAO;aAC5B;YACD,IAAI,EAAE,WAAW,CAAC,IAAI;YACtB,IAAI,EAAE;gBACF,OAAO,EAAE;oBACL,GAAG,EAAE;wBACD,cAAc,EAAE,IAAI;wBACpB,gBAAgB,EAAE,IAAI;wBACtB,YAAY,EAAE,YAAY;qBAC7B;iBAEJ;aACF;SACJ,CAAC;QAEF,IAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACxB,OAAO;gBACL,GAAG,cAAc;gBACjB,MAAM,EAAE,KAAK;aACd,CAAA;QACH,CAAC;QACD,OAAO;YACL,GAAG,cAAc;YACjB,KAAK,EAAE,KAAK;SACb,CAAA;IACH,CAAC;CACF;AA/ED,kEA+EC"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
export interface FirebaseMessaging {
|
|
2
|
+
send(message: Message, dryRun?: boolean): Promise<string>;
|
|
3
|
+
sendEachForMulticast(message: MulticastMessage, dryRun?: boolean): Promise<BatchResponse>;
|
|
4
|
+
sendMulticast(message: MulticastMessage, dryRun?: boolean): Promise<BatchResponse>;
|
|
5
|
+
}
|
|
6
|
+
export interface FirebaseApp {
|
|
7
|
+
messaging(): FirebaseMessaging;
|
|
8
|
+
}
|
|
9
|
+
export interface BaseMessage {
|
|
10
|
+
data?: {
|
|
11
|
+
[key: string]: string;
|
|
12
|
+
};
|
|
13
|
+
notification?: Notification;
|
|
14
|
+
android?: AndroidConfig;
|
|
15
|
+
webpush?: any;
|
|
16
|
+
apns?: ApnsConfig;
|
|
17
|
+
fcmOptions?: FcmOptions;
|
|
18
|
+
}
|
|
19
|
+
export interface TokenMessage extends BaseMessage {
|
|
20
|
+
token: string;
|
|
21
|
+
}
|
|
22
|
+
export interface TopicMessage extends BaseMessage {
|
|
23
|
+
topic: string;
|
|
24
|
+
}
|
|
25
|
+
export interface ConditionMessage extends BaseMessage {
|
|
26
|
+
condition: string;
|
|
27
|
+
}
|
|
28
|
+
export type Message = TokenMessage | TopicMessage | ConditionMessage;
|
|
29
|
+
export interface MulticastMessage extends BaseMessage {
|
|
30
|
+
tokens: string[];
|
|
31
|
+
}
|
|
32
|
+
export interface Notification {
|
|
33
|
+
title?: string;
|
|
34
|
+
body?: string;
|
|
35
|
+
imageUrl?: string;
|
|
36
|
+
}
|
|
37
|
+
export interface AndroidConfig {
|
|
38
|
+
collapseKey?: string;
|
|
39
|
+
priority?: ('high' | 'normal');
|
|
40
|
+
ttl?: number;
|
|
41
|
+
restrictedPackageName?: string;
|
|
42
|
+
data?: {
|
|
43
|
+
[key: string]: string;
|
|
44
|
+
};
|
|
45
|
+
notification?: AndroidNotification;
|
|
46
|
+
fcmOptions?: AndroidFcmOptions;
|
|
47
|
+
}
|
|
48
|
+
export interface AndroidNotification {
|
|
49
|
+
title?: string;
|
|
50
|
+
body?: string;
|
|
51
|
+
icon?: string;
|
|
52
|
+
color?: string;
|
|
53
|
+
sound?: string;
|
|
54
|
+
tag?: string;
|
|
55
|
+
imageUrl?: string;
|
|
56
|
+
clickAction?: string;
|
|
57
|
+
bodyLocKey?: string;
|
|
58
|
+
bodyLocArgs?: string[];
|
|
59
|
+
titleLocKey?: string;
|
|
60
|
+
titleLocArgs?: string[];
|
|
61
|
+
channelId?: string;
|
|
62
|
+
ticker?: string;
|
|
63
|
+
sticky?: boolean;
|
|
64
|
+
eventTimestamp?: Date;
|
|
65
|
+
localOnly?: boolean;
|
|
66
|
+
priority?: ('min' | 'low' | 'default' | 'high' | 'max');
|
|
67
|
+
vibrateTimingsMillis?: number[];
|
|
68
|
+
defaultVibrateTimings?: boolean;
|
|
69
|
+
defaultSound?: boolean;
|
|
70
|
+
lightSettings?: LightSettings;
|
|
71
|
+
defaultLightSettings?: boolean;
|
|
72
|
+
visibility?: ('private' | 'public' | 'secret');
|
|
73
|
+
notificationCount?: number;
|
|
74
|
+
}
|
|
75
|
+
export interface LightSettings {
|
|
76
|
+
color: string;
|
|
77
|
+
lightOnDurationMillis: number;
|
|
78
|
+
lightOffDurationMillis: number;
|
|
79
|
+
}
|
|
80
|
+
export interface AndroidFcmOptions {
|
|
81
|
+
analyticsLabel?: string;
|
|
82
|
+
}
|
|
83
|
+
export interface ApnsConfig {
|
|
84
|
+
headers?: {
|
|
85
|
+
[key: string]: string;
|
|
86
|
+
};
|
|
87
|
+
payload?: ApnsPayload;
|
|
88
|
+
fcmOptions?: ApnsFcmOptions;
|
|
89
|
+
}
|
|
90
|
+
export interface ApnsPayload {
|
|
91
|
+
aps: Aps;
|
|
92
|
+
[customData: string]: any;
|
|
93
|
+
}
|
|
94
|
+
export interface Aps {
|
|
95
|
+
alert?: string | ApsAlert;
|
|
96
|
+
badge?: number;
|
|
97
|
+
sound?: string | CriticalSound;
|
|
98
|
+
contentAvailable?: boolean;
|
|
99
|
+
mutableContent?: boolean;
|
|
100
|
+
category?: string;
|
|
101
|
+
threadId?: string;
|
|
102
|
+
[customData: string]: any;
|
|
103
|
+
}
|
|
104
|
+
export interface ApsAlert {
|
|
105
|
+
title?: string;
|
|
106
|
+
subtitle?: string;
|
|
107
|
+
body?: string;
|
|
108
|
+
locKey?: string;
|
|
109
|
+
locArgs?: string[];
|
|
110
|
+
titleLocKey?: string;
|
|
111
|
+
titleLocArgs?: string[];
|
|
112
|
+
subtitleLocKey?: string;
|
|
113
|
+
subtitleLocArgs?: string[];
|
|
114
|
+
actionLocKey?: string;
|
|
115
|
+
launchImage?: string;
|
|
116
|
+
}
|
|
117
|
+
export interface CriticalSound {
|
|
118
|
+
critical?: boolean;
|
|
119
|
+
name: string;
|
|
120
|
+
volume?: number;
|
|
121
|
+
}
|
|
122
|
+
export interface ApnsFcmOptions {
|
|
123
|
+
analyticsLabel?: string;
|
|
124
|
+
imageUrl?: string;
|
|
125
|
+
}
|
|
126
|
+
export interface FcmOptions {
|
|
127
|
+
analyticsLabel?: string;
|
|
128
|
+
}
|
|
129
|
+
export interface BatchResponse {
|
|
130
|
+
responses: SendResponse[];
|
|
131
|
+
successCount: number;
|
|
132
|
+
failureCount: number;
|
|
133
|
+
}
|
|
134
|
+
export interface SendResponse {
|
|
135
|
+
success: boolean;
|
|
136
|
+
messageId?: string;
|
|
137
|
+
error?: FirebaseError;
|
|
138
|
+
}
|
|
139
|
+
export interface FirebaseError {
|
|
140
|
+
code: string;
|
|
141
|
+
message: string;
|
|
142
|
+
stack?: string;
|
|
143
|
+
toJSON(): object;
|
|
144
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"firebase.interface.js","sourceRoot":"","sources":["../../lib/push-notification/firebase.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { PUSH_NOTIFICATION_PROVIDERS } from "./constant";
|
|
2
|
+
import { FCMPushNotificationProvider } from "./fcm-push-notification.provider";
|
|
3
|
+
import { PushNotificationModuleAsyncOptions, PushNotificationModuleOptions, PushNotificationProviderAsyncOptions, PushNotificationProviderModuleOptionsFactory, PushNotificationProviderOptions } from "./push-notification-module.interface";
|
|
4
|
+
import { DeviceToken, FCMPushNotificationOption, PlatformOS, PushNotificationOption, PushNotificationPlatform } from "./push-notification.interface";
|
|
5
|
+
import { PushNotificationModule } from "./push-notification.module";
|
|
6
|
+
import { PushNotificationProvider } from "./push-notification.provider";
|
|
7
|
+
import { DefaultProviderManager, ProviderManager } from "./push-notification-provider.manager";
|
|
8
|
+
import { PushNotificationService } from "./push-notification.service";
|
|
9
|
+
import { DefaultFirebasePushNotificationProviderModuleOptionsFactory } from "./push-notification-provider-module.factory";
|
|
10
|
+
import { IUserTokenStore, InMemoryUserTokenStore, TokenId, UserTokenStore } from "./user-token.store";
|
|
11
|
+
export { PushNotificationService, FCMPushNotificationOption, PushNotificationOption, FCMPushNotificationProvider, PushNotificationProvider, PushNotificationPlatform, PlatformOS, ProviderManager, PushNotificationProviderOptions, PushNotificationModuleOptions, PushNotificationProviderModuleOptionsFactory, PushNotificationProviderAsyncOptions, PushNotificationModuleAsyncOptions, PUSH_NOTIFICATION_PROVIDERS, PushNotificationModule, DefaultProviderManager, DeviceToken, DefaultFirebasePushNotificationProviderModuleOptionsFactory, TokenId, IUserTokenStore, UserTokenStore, InMemoryUserTokenStore, };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InMemoryUserTokenStore = exports.UserTokenStore = exports.DefaultFirebasePushNotificationProviderModuleOptionsFactory = exports.DefaultProviderManager = exports.PushNotificationModule = exports.PUSH_NOTIFICATION_PROVIDERS = exports.ProviderManager = exports.PlatformOS = exports.PushNotificationProvider = exports.FCMPushNotificationProvider = exports.PushNotificationService = void 0;
|
|
4
|
+
const constant_1 = require("./constant");
|
|
5
|
+
Object.defineProperty(exports, "PUSH_NOTIFICATION_PROVIDERS", { enumerable: true, get: function () { return constant_1.PUSH_NOTIFICATION_PROVIDERS; } });
|
|
6
|
+
const fcm_push_notification_provider_1 = require("./fcm-push-notification.provider");
|
|
7
|
+
Object.defineProperty(exports, "FCMPushNotificationProvider", { enumerable: true, get: function () { return fcm_push_notification_provider_1.FCMPushNotificationProvider; } });
|
|
8
|
+
const push_notification_interface_1 = require("./push-notification.interface");
|
|
9
|
+
Object.defineProperty(exports, "PlatformOS", { enumerable: true, get: function () { return push_notification_interface_1.PlatformOS; } });
|
|
10
|
+
const push_notification_module_1 = require("./push-notification.module");
|
|
11
|
+
Object.defineProperty(exports, "PushNotificationModule", { enumerable: true, get: function () { return push_notification_module_1.PushNotificationModule; } });
|
|
12
|
+
const push_notification_provider_1 = require("./push-notification.provider");
|
|
13
|
+
Object.defineProperty(exports, "PushNotificationProvider", { enumerable: true, get: function () { return push_notification_provider_1.PushNotificationProvider; } });
|
|
14
|
+
const push_notification_provider_manager_1 = require("./push-notification-provider.manager");
|
|
15
|
+
Object.defineProperty(exports, "DefaultProviderManager", { enumerable: true, get: function () { return push_notification_provider_manager_1.DefaultProviderManager; } });
|
|
16
|
+
Object.defineProperty(exports, "ProviderManager", { enumerable: true, get: function () { return push_notification_provider_manager_1.ProviderManager; } });
|
|
17
|
+
const push_notification_service_1 = require("./push-notification.service");
|
|
18
|
+
Object.defineProperty(exports, "PushNotificationService", { enumerable: true, get: function () { return push_notification_service_1.PushNotificationService; } });
|
|
19
|
+
const push_notification_provider_module_factory_1 = require("./push-notification-provider-module.factory");
|
|
20
|
+
Object.defineProperty(exports, "DefaultFirebasePushNotificationProviderModuleOptionsFactory", { enumerable: true, get: function () { return push_notification_provider_module_factory_1.DefaultFirebasePushNotificationProviderModuleOptionsFactory; } });
|
|
21
|
+
const user_token_store_1 = require("./user-token.store");
|
|
22
|
+
Object.defineProperty(exports, "InMemoryUserTokenStore", { enumerable: true, get: function () { return user_token_store_1.InMemoryUserTokenStore; } });
|
|
23
|
+
Object.defineProperty(exports, "UserTokenStore", { enumerable: true, get: function () { return user_token_store_1.UserTokenStore; } });
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/push-notification/index.ts"],"names":[],"mappings":";;;AAAA,yCAAyD;AAyBvD,4GAzBO,sCAA2B,OAyBP;AAxB7B,qFAA+E;AAc7E,4GAdO,4DAA2B,OAcP;AAZ7B,+EAAqJ;AAenJ,2FAf+C,wCAAU,OAe/C;AAdZ,yEAAoE;AAsBlE,uGAtBO,iDAAsB,OAsBP;AArBxB,6EAAwE;AAWtE,yGAXO,qDAAwB,OAWP;AAV1B,6FAA+F;AAqB7F,uGArBO,2DAAsB,OAqBP;AARtB,gGAb+B,oDAAe,OAa/B;AAZjB,2EAAsE;AAKpE,wGALO,mDAAuB,OAKP;AAJzB,2GAA0H;AAqBxH,4IArBO,uGAA2D,OAqBP;AApB7D,yDAAsG;AAwBpG,uGAxBwB,yCAAsB,OAwBxB;AADtB,+FAvByD,iCAAc,OAuBzD"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ModuleMetadata, Type } from "@nestjs/common";
|
|
2
|
+
import { PushNotificationOption } from "./push-notification.interface";
|
|
3
|
+
import { ProviderManager } from "./push-notification-provider.manager";
|
|
4
|
+
import { UserTokenStore } from "./user-token.store";
|
|
5
|
+
export type PushNotificationProviderOptions = PushNotificationOption;
|
|
6
|
+
export type PushNotificationModuleOptions = {
|
|
7
|
+
name?: string;
|
|
8
|
+
providers: Array<PushNotificationProviderOptions>;
|
|
9
|
+
providerManager?: Type<ProviderManager>;
|
|
10
|
+
userTokenStore?: Type<UserTokenStore>;
|
|
11
|
+
};
|
|
12
|
+
export interface PushNotificationProviderModuleOptionsFactory {
|
|
13
|
+
createProviderOptions(): Promise<PushNotificationProviderOptions> | PushNotificationProviderOptions;
|
|
14
|
+
}
|
|
15
|
+
export interface PushNotificationProviderAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
|
|
16
|
+
useExisting?: Type<PushNotificationProviderModuleOptionsFactory>;
|
|
17
|
+
useClass?: Type<PushNotificationProviderModuleOptionsFactory>;
|
|
18
|
+
useFactory?: (...args: any[]) => Promise<PushNotificationProviderOptions> | PushNotificationProviderOptions;
|
|
19
|
+
inject?: any[];
|
|
20
|
+
name: string | symbol;
|
|
21
|
+
}
|
|
22
|
+
export interface ProviderAsyncOptions<T = any> extends Pick<ModuleMetadata, 'imports'> {
|
|
23
|
+
useExisting?: Type<T>;
|
|
24
|
+
useClass?: Type<T>;
|
|
25
|
+
useFactory?: (...args: any[]) => T | Promise<T>;
|
|
26
|
+
inject?: any[];
|
|
27
|
+
}
|
|
28
|
+
export interface PushNotificationModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
|
|
29
|
+
name?: string;
|
|
30
|
+
providers: Array<PushNotificationProviderAsyncOptions>;
|
|
31
|
+
providerManager?: Type<ProviderManager> | ProviderAsyncOptions<ProviderManager>;
|
|
32
|
+
userTokenStore?: Type<UserTokenStore> | ProviderAsyncOptions<UserTokenStore>;
|
|
33
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"push-notification-module.interface.js","sourceRoot":"","sources":["../../lib/push-notification/push-notification-module.interface.ts"],"names":[],"mappings":";;AA6CG,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { PushNotificationProviderModuleOptionsFactory } from "./push-notification-module.interface";
|
|
2
|
+
import { FCMPushNotificationOption } from "./push-notification.interface";
|
|
3
|
+
export declare class DefaultFirebasePushNotificationProviderModuleOptionsFactory implements PushNotificationProviderModuleOptionsFactory {
|
|
4
|
+
createProviderOptions(): FCMPushNotificationOption | Promise<FCMPushNotificationOption>;
|
|
5
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DefaultFirebasePushNotificationProviderModuleOptionsFactory = void 0;
|
|
4
|
+
class DefaultFirebasePushNotificationProviderModuleOptionsFactory {
|
|
5
|
+
createProviderOptions() {
|
|
6
|
+
return {
|
|
7
|
+
type: "firebase",
|
|
8
|
+
serviceAccount: process.env.PUSH_FIREBASE_SERVICE_ACCOUNT
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.DefaultFirebasePushNotificationProviderModuleOptionsFactory = DefaultFirebasePushNotificationProviderModuleOptionsFactory;
|
|
13
|
+
//# sourceMappingURL=push-notification-provider-module.factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"push-notification-provider-module.factory.js","sourceRoot":"","sources":["../../lib/push-notification/push-notification-provider-module.factory.ts"],"names":[],"mappings":";;;AAGA,MAAa,2DAA2D;IACtE,qBAAqB;QACnB,OAAO;YACL,IAAI,EAAE,UAAU;YAChB,cAAc,EAAE,OAAO,CAAC,GAAG,CAAC,6BAA6B;SAC1D,CAAA;IACH,CAAC;CAEF;AARD,kIAQC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { PushNotificationOption } from "./push-notification.interface";
|
|
2
|
+
import { PushNotificationProvider } from "./push-notification.provider";
|
|
3
|
+
export declare class PushNotificationProviderFactory {
|
|
4
|
+
static create(option: PushNotificationOption): PushNotificationProvider;
|
|
5
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PushNotificationProviderFactory = void 0;
|
|
4
|
+
const fcm_push_notification_provider_1 = require("./fcm-push-notification.provider");
|
|
5
|
+
class PushNotificationProviderFactory {
|
|
6
|
+
static create(option) {
|
|
7
|
+
switch (option.type) {
|
|
8
|
+
case "firebase":
|
|
9
|
+
return new fcm_push_notification_provider_1.FCMPushNotificationProvider(option);
|
|
10
|
+
default:
|
|
11
|
+
throw new Error(`type ${option.type} not supported`);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.PushNotificationProviderFactory = PushNotificationProviderFactory;
|
|
16
|
+
//# sourceMappingURL=push-notification-provider.factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"push-notification-provider.factory.js","sourceRoot":"","sources":["../../lib/push-notification/push-notification-provider.factory.ts"],"names":[],"mappings":";;;AAAA,qFAA+E;AAI/E,MAAa,+BAA+B;IACnC,MAAM,CAAC,MAAM,CAClB,MAA8B;QAG9B,QAAO,MAAM,CAAC,IAAI,EAAE,CAAC;YACnB,KAAK,UAAU;gBACb,OAAO,IAAI,4DAA2B,CAAC,MAAM,CAAC,CAAC;YACjD;gBACE,MAAM,IAAI,KAAK,CAAC,QAAQ,MAAM,CAAC,IAAI,gBAAgB,CAAC,CAAC;QACzD,CAAC;IAEH,CAAC;CACF;AAbD,0EAaC"}
|