@nathapp/nestjs-notification 1.0.0-rc.5 → 1.0.1

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.
Files changed (102) hide show
  1. package/README.md +3 -3
  2. package/dist/email/constant.js +1 -0
  3. package/dist/email/constant.js.map +1 -0
  4. package/dist/email/email-provider.factory.js +1 -0
  5. package/dist/email/email-provider.factory.js.map +1 -0
  6. package/dist/email/email.interface.js +1 -0
  7. package/dist/email/email.interface.js.map +1 -0
  8. package/dist/email/email.module.d.ts +3 -0
  9. package/dist/email/email.module.js +20 -5
  10. package/dist/email/email.module.js.map +1 -0
  11. package/dist/email/email.provider.d.ts +2 -0
  12. package/dist/email/email.provider.js +29 -7
  13. package/dist/email/email.provider.js.map +1 -0
  14. package/dist/email/email.service.d.ts +1 -1
  15. package/dist/email/email.service.js +3 -2
  16. package/dist/email/email.service.js.map +1 -0
  17. package/dist/email/index.d.ts +2 -2
  18. package/dist/email/index.js +3 -1
  19. package/dist/email/index.js.map +1 -0
  20. package/dist/index.d.ts +1 -0
  21. package/dist/index.js +2 -0
  22. package/dist/index.js.map +1 -0
  23. package/dist/interface/index.d.ts +4 -2
  24. package/dist/interface/index.js +1 -0
  25. package/dist/interface/index.js.map +1 -0
  26. package/dist/interface/message.interface.d.ts +13 -0
  27. package/dist/interface/message.interface.js +1 -0
  28. package/dist/interface/message.interface.js.map +1 -0
  29. package/dist/interface/payload.inteface.d.ts +22 -0
  30. package/dist/interface/payload.inteface.js +3 -0
  31. package/dist/interface/payload.inteface.js.map +1 -0
  32. package/dist/interface/result.interface.d.ts +5 -0
  33. package/dist/interface/result.interface.js +1 -0
  34. package/dist/interface/result.interface.js.map +1 -0
  35. package/dist/notification/constant.js +1 -0
  36. package/dist/notification/constant.js.map +1 -0
  37. package/dist/notification/index.d.ts +2 -2
  38. package/dist/notification/index.js +1 -0
  39. package/dist/notification/index.js.map +1 -0
  40. package/dist/notification/notification.module.d.ts +28 -5
  41. package/dist/notification/notification.module.js +149 -10
  42. package/dist/notification/notification.module.js.map +1 -0
  43. package/dist/notification/notification.service.d.ts +14 -3
  44. package/dist/notification/notification.service.js +135 -10
  45. package/dist/notification/notification.service.js.map +1 -0
  46. package/dist/push-notification/constant.d.ts +1 -0
  47. package/dist/push-notification/constant.js +5 -0
  48. package/dist/push-notification/constant.js.map +1 -0
  49. package/dist/push-notification/fcm-push-notification.provider.d.ts +13 -0
  50. package/dist/push-notification/fcm-push-notification.provider.js +78 -0
  51. package/dist/push-notification/fcm-push-notification.provider.js.map +1 -0
  52. package/dist/push-notification/firebase.interface.d.ts +144 -0
  53. package/dist/push-notification/firebase.interface.js +3 -0
  54. package/dist/push-notification/firebase.interface.js.map +1 -0
  55. package/dist/push-notification/index.d.ts +11 -0
  56. package/dist/push-notification/index.js +24 -0
  57. package/dist/push-notification/index.js.map +1 -0
  58. package/dist/push-notification/push-notification-module.interface.d.ts +33 -0
  59. package/dist/push-notification/push-notification-module.interface.js +4 -0
  60. package/dist/push-notification/push-notification-module.interface.js.map +1 -0
  61. package/dist/push-notification/push-notification-provider-module.factory.d.ts +5 -0
  62. package/dist/push-notification/push-notification-provider-module.factory.js +13 -0
  63. package/dist/push-notification/push-notification-provider-module.factory.js.map +1 -0
  64. package/dist/push-notification/push-notification-provider.factory.d.ts +5 -0
  65. package/dist/push-notification/push-notification-provider.factory.js +16 -0
  66. package/dist/push-notification/push-notification-provider.factory.js.map +1 -0
  67. package/dist/push-notification/push-notification-provider.manager.d.ts +13 -0
  68. package/dist/push-notification/push-notification-provider.manager.js +38 -0
  69. package/dist/push-notification/push-notification-provider.manager.js.map +1 -0
  70. package/dist/push-notification/push-notification.interface.d.ts +16 -0
  71. package/dist/push-notification/push-notification.interface.js +11 -0
  72. package/dist/push-notification/push-notification.interface.js.map +1 -0
  73. package/dist/push-notification/push-notification.module.d.ts +15 -0
  74. package/dist/push-notification/push-notification.module.js +189 -0
  75. package/dist/push-notification/push-notification.module.js.map +1 -0
  76. package/dist/push-notification/push-notification.provider.d.ts +12 -0
  77. package/dist/push-notification/push-notification.provider.js +7 -0
  78. package/dist/push-notification/push-notification.provider.js.map +1 -0
  79. package/dist/push-notification/push-notification.service.d.ts +15 -0
  80. package/dist/push-notification/push-notification.service.js +66 -0
  81. package/dist/push-notification/push-notification.service.js.map +1 -0
  82. package/dist/push-notification/user-token.store.d.ts +19 -0
  83. package/dist/push-notification/user-token.store.js +44 -0
  84. package/dist/push-notification/user-token.store.js.map +1 -0
  85. package/dist/sms/index.js +1 -0
  86. package/dist/sms/index.js.map +1 -0
  87. package/dist/sms/sms.service.js +1 -0
  88. package/dist/sms/sms.service.js.map +1 -0
  89. package/dist/template/constant.js +1 -0
  90. package/dist/template/constant.js.map +1 -0
  91. package/dist/template/fake-template.loader.d.ts +3 -0
  92. package/dist/template/fake-template.loader.js +15 -1
  93. package/dist/template/fake-template.loader.js.map +1 -0
  94. package/dist/template/index.d.ts +2 -2
  95. package/dist/template/index.js +3 -1
  96. package/dist/template/index.js.map +1 -0
  97. package/dist/template/template.loader.js +3 -2
  98. package/dist/template/template.loader.js.map +1 -0
  99. package/dist/template/template.service.js +3 -2
  100. package/dist/template/template.service.js.map +1 -0
  101. package/package.json +13 -22
  102. package/.eslintrc.js +0 -24
@@ -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,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=firebase.interface.js.map
@@ -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,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ ;
4
+ //# sourceMappingURL=push-notification-module.interface.js.map
@@ -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"}
@@ -0,0 +1,13 @@
1
+ import { PushNotificationProvider } from "./push-notification.provider";
2
+ import { PlatformOS } from "./push-notification.interface";
3
+ export declare abstract class ProviderManager {
4
+ abstract getProvider(paltform?: PlatformOS): PushNotificationProvider;
5
+ abstract get defaultProvider(): PushNotificationProvider;
6
+ }
7
+ export declare class DefaultProviderManager extends ProviderManager {
8
+ private readonly _defaultProvider;
9
+ private readonly keysProviders;
10
+ constructor(providers: PushNotificationProvider[]);
11
+ get defaultProvider(): PushNotificationProvider;
12
+ getProvider(paltform?: PlatformOS): PushNotificationProvider;
13
+ }
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DefaultProviderManager = exports.ProviderManager = void 0;
4
+ const push_notification_interface_1 = require("./push-notification.interface");
5
+ class ProviderManager {
6
+ }
7
+ exports.ProviderManager = ProviderManager;
8
+ class DefaultProviderManager extends ProviderManager {
9
+ constructor(providers) {
10
+ super();
11
+ this.keysProviders = {};
12
+ if (providers.length == 0) {
13
+ throw new Error("please provide at lease one PushNotificationProvider");
14
+ }
15
+ this._defaultProvider = providers[0];
16
+ providers.forEach(item => {
17
+ this.keysProviders[item.type] = item;
18
+ });
19
+ }
20
+ get defaultProvider() {
21
+ return this._defaultProvider;
22
+ }
23
+ getProvider(paltform) {
24
+ let provider = undefined;
25
+ if (paltform == push_notification_interface_1.PlatformOS.android || paltform == push_notification_interface_1.PlatformOS.ios) {
26
+ provider = this.keysProviders["firebase"];
27
+ }
28
+ else if (paltform == "huawei") {
29
+ provider = this.keysProviders["hms"];
30
+ }
31
+ if (!provider) {
32
+ provider = this.defaultProvider;
33
+ }
34
+ return provider;
35
+ }
36
+ }
37
+ exports.DefaultProviderManager = DefaultProviderManager;
38
+ //# sourceMappingURL=push-notification-provider.manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"push-notification-provider.manager.js","sourceRoot":"","sources":["../../lib/push-notification/push-notification-provider.manager.ts"],"names":[],"mappings":";;;AAEA,+EAA2D;AAG3D,MAAsB,eAAe;CAMpC;AAND,0CAMC;AAED,MAAa,sBAAuB,SAAQ,eAAe;IAMzD,YAAY,SAAqC;QAC/C,KAAK,EAAE,CAAC;QAHO,kBAAa,GAA6C,EAAE,CAAC;QAI5E,IAAI,SAAS,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;YAC1B,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;QAC1E,CAAC;QACD,IAAI,CAAC,gBAAgB,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;QACrC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YACvB,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;QACvC,CAAC,CAAC,CAAC;IACL,CAAC;IAED,IAAI,eAAe;QACjB,OAAO,IAAI,CAAC,gBAAgB,CAAC;IAC/B,CAAC;IAED,WAAW,CAAC,QAAqB;QAC/B,IAAI,QAAQ,GAA6B,SAAS,CAAC;QAEnD,IAAI,QAAQ,IAAI,wCAAU,CAAC,OAAO,IAAI,QAAQ,IAAI,wCAAU,CAAC,GAAG,EAAE,CAAC;YACjE,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;QAC5C,CAAC;aAAM,IAAI,QAAQ,IAAI,QAAQ,EAAE,CAAC;YAChC,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QACvC,CAAC;QAED,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,QAAQ,GAAG,IAAI,CAAC,eAAe,CAAC;QAClC,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;CAGF;AArCD,wDAqCC"}
@@ -0,0 +1,16 @@
1
+ export declare enum PlatformOS {
2
+ android = "android",
3
+ ios = "ios",
4
+ huawei = "huawei"
5
+ }
6
+ export interface DeviceToken {
7
+ type: PlatformOS;
8
+ data: string;
9
+ }
10
+ export type PushNotificationPlatform = "firebase" | "hms";
11
+ export type PushNotificationOption = FCMPushNotificationOption;
12
+ export interface FCMPushNotificationOption {
13
+ readonly type: "firebase";
14
+ readonly serviceAccount: string;
15
+ readonly databaseUrl?: string;
16
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PlatformOS = void 0;
4
+ var PlatformOS;
5
+ (function (PlatformOS) {
6
+ PlatformOS["android"] = "android";
7
+ PlatformOS["ios"] = "ios";
8
+ PlatformOS["huawei"] = "huawei";
9
+ })(PlatformOS || (exports.PlatformOS = PlatformOS = {}));
10
+ ;
11
+ //# sourceMappingURL=push-notification.interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"push-notification.interface.js","sourceRoot":"","sources":["../../lib/push-notification/push-notification.interface.ts"],"names":[],"mappings":";;;AAAA,IAAY,UAIX;AAJD,WAAY,UAAU;IACpB,iCAAmB,CAAA;IACnB,yBAAW,CAAA;IACX,+BAAiB,CAAA;AACnB,CAAC,EAJW,UAAU,0BAAV,UAAU,QAIrB;AAAA,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { DynamicModule } from '@nestjs/common';
2
+ import { PushNotificationModuleAsyncOptions, PushNotificationModuleOptions } from './push-notification-module.interface';
3
+ export declare class PushNotificationModule {
4
+ static register(options: PushNotificationModuleOptions): DynamicModule;
5
+ static registerAsync(options: PushNotificationModuleAsyncOptions): DynamicModule;
6
+ private static sanitizeModuleOptions;
7
+ private static createProviderManager;
8
+ private static createDefaultProviderManager;
9
+ private static createUserTokenStore;
10
+ private static createDefaultUserTokenStore;
11
+ private static createPushNotificationService;
12
+ private static createAsyncProviders;
13
+ private static createAsyncOptionsProvider;
14
+ private static createFactoryWrapper;
15
+ }
@@ -0,0 +1,189 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var PushNotificationModule_1;
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.PushNotificationModule = void 0;
11
+ const common_1 = require("@nestjs/common");
12
+ const push_notification_provider_factory_1 = require("./push-notification-provider.factory");
13
+ const push_notification_provider_manager_1 = require("./push-notification-provider.manager");
14
+ const push_notification_service_1 = require("./push-notification.service");
15
+ const constant_1 = require("./constant");
16
+ const user_token_store_1 = require("./user-token.store");
17
+ const defaultOptions = {};
18
+ let PushNotificationModule = PushNotificationModule_1 = class PushNotificationModule {
19
+ static register(options) {
20
+ options = this.sanitizeModuleOptions(options);
21
+ const providerOptions = options.providers;
22
+ const pushProviders = (providerOptions || []).map(item => {
23
+ return push_notification_provider_factory_1.PushNotificationProviderFactory.create(item);
24
+ });
25
+ const providers = {
26
+ provide: constant_1.PUSH_NOTIFICATION_PROVIDERS,
27
+ useValue: pushProviders,
28
+ };
29
+ const provideProviderManager = this.createProviderManager(options);
30
+ const userTokenStore = this.createUserTokenStore(options);
31
+ const provideService = this.createPushNotificationService();
32
+ return {
33
+ module: PushNotificationModule_1,
34
+ providers: [providers, provideProviderManager, provideService, userTokenStore],
35
+ exports: [providers, provideProviderManager, provideService, userTokenStore],
36
+ };
37
+ }
38
+ static registerAsync(options) {
39
+ options = this.sanitizeModuleOptions(options);
40
+ const providersOptions = options.providers;
41
+ const innerProviders = providersOptions.reduce((accProviders, item) => accProviders
42
+ .concat(this.createAsyncProviders(item)), []);
43
+ const imports = providersOptions.reduce((accImports, option) => option.imports && !accImports.includes(option.imports)
44
+ ? accImports.concat(option.imports)
45
+ : accImports, []);
46
+ const providers = {
47
+ provide: constant_1.PUSH_NOTIFICATION_PROVIDERS,
48
+ useFactory(...args) {
49
+ return args;
50
+ },
51
+ inject: [...options.providers.map(item => item.name)]
52
+ };
53
+ const provideProviderManager = this.createProviderManager(options);
54
+ const userTokenStore = this.createUserTokenStore(options);
55
+ const provideService = this.createPushNotificationService();
56
+ return {
57
+ module: PushNotificationModule_1,
58
+ imports,
59
+ providers: [...innerProviders, providers, provideProviderManager, provideService, userTokenStore],
60
+ exports: [providers, provideProviderManager, provideService, userTokenStore],
61
+ };
62
+ }
63
+ static sanitizeModuleOptions(options) {
64
+ options = { ...defaultOptions, ...options };
65
+ return options;
66
+ }
67
+ static createProviderManager(options) {
68
+ const providerOptions = options.providerManager;
69
+ if (!providerOptions) {
70
+ return this.createDefaultProviderManager();
71
+ }
72
+ if (!isProviderAsyncOptions(providerOptions)) {
73
+ return {
74
+ provide: push_notification_provider_manager_1.ProviderManager,
75
+ useClass: options.providerManager,
76
+ };
77
+ }
78
+ if (providerOptions.useFactory) {
79
+ return {
80
+ provide: push_notification_provider_manager_1.ProviderManager,
81
+ useFactory(...args) {
82
+ return providerOptions.useFactory(...args);
83
+ },
84
+ inject: providerOptions.inject || [],
85
+ };
86
+ }
87
+ return {
88
+ provide: push_notification_provider_manager_1.ProviderManager,
89
+ useFactory(manager) {
90
+ return manager;
91
+ },
92
+ inject: [providerOptions.useClass || providerOptions.useExisting],
93
+ };
94
+ }
95
+ static createDefaultProviderManager() {
96
+ return {
97
+ provide: push_notification_provider_manager_1.ProviderManager,
98
+ useFactory(providers) {
99
+ return new push_notification_provider_manager_1.DefaultProviderManager(providers);
100
+ },
101
+ inject: [constant_1.PUSH_NOTIFICATION_PROVIDERS],
102
+ };
103
+ }
104
+ static createUserTokenStore(options) {
105
+ const providerOptions = options.userTokenStore;
106
+ if (!providerOptions) {
107
+ return this.createDefaultUserTokenStore();
108
+ }
109
+ if (!isProviderAsyncOptions(providerOptions)) {
110
+ return {
111
+ provide: user_token_store_1.UserTokenStore,
112
+ useClass: options.userTokenStore,
113
+ };
114
+ }
115
+ if (providerOptions.useFactory) {
116
+ return {
117
+ provide: user_token_store_1.UserTokenStore,
118
+ useFactory(...args) {
119
+ return providerOptions.useFactory(...args);
120
+ },
121
+ inject: providerOptions.inject || [],
122
+ };
123
+ }
124
+ return {
125
+ provide: user_token_store_1.UserTokenStore,
126
+ useFactory(store) {
127
+ return store;
128
+ },
129
+ inject: [providerOptions.useClass || providerOptions.useExisting],
130
+ };
131
+ }
132
+ static createDefaultUserTokenStore() {
133
+ return {
134
+ provide: user_token_store_1.UserTokenStore,
135
+ useFactory() {
136
+ return new user_token_store_1.InMemoryUserTokenStore();
137
+ },
138
+ };
139
+ }
140
+ static createPushNotificationService() {
141
+ return {
142
+ provide: push_notification_service_1.PushNotificationService,
143
+ useFactory(manager, userTokenStore) {
144
+ return new push_notification_service_1.PushNotificationService(manager, userTokenStore);
145
+ },
146
+ inject: [push_notification_provider_manager_1.ProviderManager, user_token_store_1.UserTokenStore],
147
+ };
148
+ }
149
+ static createAsyncProviders(options) {
150
+ if (options.useExisting || options.useFactory) {
151
+ return [this.createAsyncOptionsProvider(options)];
152
+ }
153
+ return [
154
+ this.createAsyncOptionsProvider(options),
155
+ {
156
+ provide: options.useClass,
157
+ useClass: options.useClass,
158
+ },
159
+ ];
160
+ }
161
+ static createAsyncOptionsProvider(options) {
162
+ if (options.useFactory) {
163
+ return {
164
+ provide: options.name,
165
+ useFactory: this.createFactoryWrapper(options.useFactory),
166
+ inject: options.inject || [],
167
+ };
168
+ }
169
+ return {
170
+ provide: options.name,
171
+ useFactory: this.createFactoryWrapper((optionsFactory) => optionsFactory.createProviderOptions()),
172
+ inject: [options.useExisting || options.useClass],
173
+ };
174
+ }
175
+ static createFactoryWrapper(useFactory) {
176
+ return async (...args) => {
177
+ const clientOptions = await useFactory(...args);
178
+ return push_notification_provider_factory_1.PushNotificationProviderFactory.create(clientOptions);
179
+ };
180
+ }
181
+ };
182
+ exports.PushNotificationModule = PushNotificationModule;
183
+ exports.PushNotificationModule = PushNotificationModule = PushNotificationModule_1 = __decorate([
184
+ (0, common_1.Module)({})
185
+ ], PushNotificationModule);
186
+ const isProviderAsyncOptions = (options) => {
187
+ return 'useExisting' in options || 'useClass' in options || 'useFactory' in options;
188
+ };
189
+ //# sourceMappingURL=push-notification.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"push-notification.module.js","sourceRoot":"","sources":["../../lib/push-notification/push-notification.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAOwB;AAExB,6FAAuF;AAEvF,6FAA+F;AAC/F,2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;aAC3B;SACF,CAAC;IACJ,CAAC;IAGO,MAAM,CAAC,0BAA0B,CACvC,OAA6C;QAE7C,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;YACvB,OAAO;gBACL,OAAO,EAAE,OAAO,CAAC,IAAI;gBACrB,UAAU,EAAE,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,UAAU,CAAC;gBACzD,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,EAAE;aAC7B,CAAC;QACJ,CAAC;QACD,OAAO;YACL,OAAO,EAAE,OAAO,CAAC,IAAI;YACrB,UAAU,EAAE,IAAI,CAAC,oBAAoB,CACnC,CAAC,cAA4D,EAAE,EAAE,CAC/D,cAAc,CAAC,qBAAqB,EAAE,CACzC;YACD,MAAM,EAAE,CAAC,OAAO,CAAC,WAAW,IAAI,OAAO,CAAC,QAAQ,CAAC;SAClD,CAAC;IACJ,CAAC;IAEO,MAAM,CAAC,oBAAoB,CACjC,UAA8D;QAE9D,OAAO,KAAK,EAAE,GAAG,IAAW,EAAE,EAAE;YAC9B,MAAM,aAAa,GAAG,MAAM,UAAU,CAAC,GAAG,IAAI,CAAC,CAAC;YAChD,OAAO,oEAA+B,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;QAC/D,CAAC,CAAC;IACJ,CAAC;CACF,CAAA;AAnNY,wDAAsB;iCAAtB,sBAAsB;IADlC,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,sBAAsB,CAmNlC;AAED,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"}
@@ -0,0 +1,12 @@
1
+ import { PushMessage, PushMessageOnly } from "../interface";
2
+ import { BatchSendResult, SendResult } from "../interface/result.interface";
3
+ import { PushNotificationPlatform } from "./push-notification.interface";
4
+ export interface IPushNotificationProvider {
5
+ send(message: PushMessage): Promise<SendResult>;
6
+ sendMulticast(tokens: string[], message: PushMessageOnly): Promise<BatchSendResult>;
7
+ }
8
+ export declare abstract class PushNotificationProvider implements IPushNotificationProvider {
9
+ abstract readonly type: PushNotificationPlatform;
10
+ abstract send(message: PushMessage): Promise<SendResult>;
11
+ abstract sendMulticast(tokens: string[], message: PushMessageOnly): Promise<BatchSendResult>;
12
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PushNotificationProvider = void 0;
4
+ class PushNotificationProvider {
5
+ }
6
+ exports.PushNotificationProvider = PushNotificationProvider;
7
+ //# sourceMappingURL=push-notification.provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"push-notification.provider.js","sourceRoot":"","sources":["../../lib/push-notification/push-notification.provider.ts"],"names":[],"mappings":";;;AAaA,MAAsB,wBAAwB;CAQ7C;AARD,4DAQC"}
@@ -0,0 +1,15 @@
1
+ import { BatchSendResult, PushMessage, PushMessageOnly, SendResult } from "../interface";
2
+ import { DeviceToken } from "./push-notification.interface";
3
+ import { ProviderManager } from "./push-notification-provider.manager";
4
+ import { TokenId, UserTokenStore } from "./user-token.store";
5
+ export declare class PushNotificationService {
6
+ private readonly providerManager;
7
+ private readonly userTokenStore;
8
+ constructor(providerManager: ProviderManager, userTokenStore: UserTokenStore);
9
+ saveUserToken(userId: string | number, token: DeviceToken): Promise<TokenId>;
10
+ getUserDeviceToken(userId: string | number): Promise<DeviceToken>;
11
+ getUserDeviceTokens(userId: string | number): Promise<DeviceToken[]>;
12
+ send(message: PushMessage): Promise<SendResult>;
13
+ sendMulticast(tokens: DeviceToken[], message: PushMessageOnly): Promise<BatchSendResult>;
14
+ private groupDevicesToken;
15
+ }